Mercurial > octave
changeset 21837:3ef630a564f8
Clean up C++ code for F__octave_link_file_dialog__.
* octave-link.cc (F__octave_link_file_dialog__): Use ovl to assign to retval in
one statement. Avoid converting it to an octave_value and then subsequently to an
integer. Simplify for loop body by incrementing iterator in for statement.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 08 Jun 2016 12:14:39 -0700 |
parents | 2049e123bf7b |
children | 30d4645ecb98 |
files | libinterp/corefcn/octave-link.cc |
diffstat | 1 files changed, 15 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/octave-link.cc Wed Jun 08 10:40:39 2016 -0700 +++ b/libinterp/corefcn/octave-link.cc Wed Jun 08 12:14:39 2016 -0700 @@ -230,36 +230,31 @@ // If 3, then retval is filename, directory, and selected index. if (nel <= 3) { - int idx = 0; if (items_lst.front ().empty ()) - { - retval(idx++) = 0; - retval(idx++) = 0; - retval(idx++) = 0; - } + retval = ovl (octave_value (0.), octave_value (0.), octave_value (0.)); else - for (std::list<std::string>::iterator it = items_lst.begin (); - it != items_lst.end (); it++) - { - retval(idx++) = *it; - - if (idx == 3) - retval(2) = atoi (retval(2).string_value ().c_str ()); - } + { + int idx = 0; + for (std::list<std::string>::iterator it = items_lst.begin (); + it != items_lst.end (); it++) + { + if (idx != 2) + retval(idx++) = *it; + else + retval(idx++) = atoi (it->c_str ()); + } + } } else { // Multiple files. - nel = items_lst.size () - 2; + nel -= 2; Cell items (dim_vector (1, nel)); std::list<std::string>::iterator it = items_lst.begin (); - for (int idx = 0; idx < nel; idx++) - { - items.xelem (idx) = *it; - it++; - } + for (int idx = 0; idx < nel; idx++, it++) + items.xelem (idx) = *it; retval = ovl (items, *it++, atoi (it->c_str ())); }