changeset 9494:ca95d991a65a

use key list order for iterating through map with for loop
author John W. Eaton <jwe@octave.org>
date Wed, 05 Aug 2009 22:11:05 -0400
parents 9035e668ca96
children 0a427d3244bf
files src/ChangeLog src/pt-eval.cc
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Aug 05 20:19:47 2009 -0400
+++ b/src/ChangeLog	Wed Aug 05 22:11:05 2009 -0400
@@ -1,5 +1,8 @@
 2009-08-05  John W. Eaton  <jwe@octave.org>
 
+	* pt-eval.cc (tree_evaluator::visit_complex_for_command):
+	Use key_list order for iterating through map.
+
 	* Makefile.in (OCT_LINK_DEPS): Also include $(RLD_FLAG) in the list.
 
 2009-08-05  John W. Eaton  <jwe@octave.org>
--- a/src/pt-eval.cc	Wed Aug 05 20:19:47 2009 -0400
+++ b/src/pt-eval.cc	Wed Aug 05 22:11:05 2009 -0400
@@ -432,17 +432,21 @@
 
       octave_lvalue key_ref = elt->lvalue ();
 
-      const Octave_map tmp_val (rhs.map_value ());
+      const Octave_map tmp_val = rhs.map_value ();
 
       tree_statement_list *loop_body = cmd.body ();
 
-      for (Octave_map::const_iterator q = tmp_val.begin (); q != tmp_val.end (); q++)
-	{
-	  octave_value key = tmp_val.key (q);
+      string_vector keys = tmp_val.keys ();
+
+      octave_idx_type nel = keys.numel ();
 
-	  const Cell val_lst = tmp_val.contents (q);
+      for (octave_idx_type i = 0; i < nel; i++)
+	{
+	  std::string key = keys[i];
 
-	  octave_idx_type n = tmp_val.numel ();
+	  const Cell val_lst = tmp_val.contents (key);
+
+	  octave_idx_type n = val_lst.numel ();
 
 	  octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst);