[svn:parrot] r41429 - trunk/runtime/parrot/library/Data/Dumper

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Sep 23 12:15:53 UTC 2009


Author: bacek
Date: Wed Sep 23 12:15:52 2009
New Revision: 41429
URL: https://trac.parrot.org/parrot/changeset/41429

Log:
[cage][core] Sort Hash keys in Capture.__dump to get predictive result.

Modified:
   trunk/runtime/parrot/library/Data/Dumper/Default.pir

Modified: trunk/runtime/parrot/library/Data/Dumper/Default.pir
==============================================================================
--- trunk/runtime/parrot/library/Data/Dumper/Default.pir	Wed Sep 23 08:57:25 2009	(r41428)
+++ trunk/runtime/parrot/library/Data/Dumper/Default.pir	Wed Sep 23 12:15:52 2009	(r41429)
@@ -421,9 +421,22 @@
     .local string subindent, indent
     (subindent, indent) = dumper.'newIndent'()
 
-    .local pmc hash, it
+    # Sort hash keys before dump to preseve order
+    # Use RMA instead os RSA because RSA doesn't have 'sort' method
+    .local pmc hash, it, keys
     hash = self.'hash'()
+    keys = new ['ResizablePMCArray']
     it = iter hash
+  dump_hash_keys_loop:
+    unless it goto dump_hash_keys_end
+    .local string key
+    key = shift it
+    push keys, key
+    goto dump_hash_keys_loop
+  dump_hash_keys_end:
+    keys.'sort'()
+
+    it = iter keys
   dump_hash_loop:
     unless it goto dump_hash_end
     if hasstuff goto dump_hash_1


More information about the parrot-commits mailing list