Mercurial > hg > octave-nkf
changeset 12056:68a4e6a2dc31 release-3-2-x
use key list order for iterating through map with for loop
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 07 Aug 2009 08:13:22 +0200 |
parents | c663c1a78c4a |
children | 73ca5cee6bb6 |
files | src/ChangeLog src/pt-eval.cc |
diffstat | 2 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +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. + 2009-08-07 Jaroslav Hajek <highegg@gmail.com> * pt-idx.cc (tree_index_expression::lvalue): Implant code from
--- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -435,17 +435,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);