Mercurial > octave
diff libinterp/corefcn/profiler.cc @ 22862:e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
* symtab.cc, call-stack.cc, comment-list.cc, defun.cc, dynamic-ld.cc,
error.cc, ft-text-renderer.cc, gl2ps-print.cc, graphics.cc, help.cc,
interpreter.cc, load-path.cc, load-save.cc, ls-mat5.cc, oct-errno.in.cc,
oct-map.cc, oct-stream.cc, octave-link.cc, profiler.cc, regexp.cc, strfind.cc,
symtab.h, txt-eng.h, urlwrite.cc, variables.cc:
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 05 Dec 2016 13:04:12 -0800 |
parents | 3a2b891d0b33 |
children | ef4d915df748 |
line wrap: on
line diff
--- a/libinterp/corefcn/profiler.cc Sat Dec 03 07:37:54 2016 -0500 +++ b/libinterp/corefcn/profiler.cc Mon Dec 05 13:04:12 2016 -0800 @@ -45,11 +45,9 @@ RowVector retval (n); octave_idx_type i = 0; - for (function_set::const_iterator p = list.begin (); p != list.end (); ++p) - { - retval(i) = *p; - ++i; - } + for (const auto& nm : list) + retval(i++) = nm; + assert (i == n); return retval; @@ -61,8 +59,8 @@ profile_data_accumulator::tree_node::~tree_node () { - for (child_map::iterator i = children.begin (); i != children.end (); ++i) - delete i->second; + for (auto& idx_tnode : children) + delete idx_tnode.second; } profile_data_accumulator::tree_node* @@ -122,9 +120,8 @@ } // Recurse on children. - for (child_map::const_iterator i = children.begin (); - i != children.end (); ++i) - i->second->build_flat (data); + for (const auto& idx_tnode : children) + idx_tnode.second->build_flat (data); } octave_value @@ -144,13 +141,12 @@ Cell rv_children (n, 1); octave_idx_type i = 0; - for (child_map::const_iterator p = children.begin (); - p != children.end (); ++p) + for (const auto& idx_tnode : children) { - const tree_node& entry = *p->second; + const tree_node& entry = *idx_tnode.second; double child_total = entry.time; - rv_indices(i) = octave_value (p->first); + rv_indices(i) = octave_value (idx_tnode.first); rv_times(i) = octave_value (entry.time); rv_calls(i) = octave_value (entry.calls); rv_children(i) = entry.get_hierarchical (&child_total);