# HG changeset patch # User John W. Eaton # Date 1566417718 14400 # Wed Aug 21 16:01:58 2019 -0400 # Node ID ff8d4dddc5e9b8fa1a7ef4c8f8392c8e80971677 # Parent a24338d5a788e1e23a42714c6a8208b646e2530b improve convert_to_const_vector diff --git a/libinterp/octave-value/ovl.cc b/libinterp/octave-value/ovl.cc --- a/libinterp/octave-value/ovl.cc +++ b/libinterp/octave-value/ovl.cc @@ -31,6 +31,19 @@ along with Octave; see the file COPYING. // We are likely to have a lot of octave_value_list objects to allocate, // so make the grow_size large. +octave_value_list::octave_value_list (const std::list& lst) +{ + size_t nel = lst.size (); + + if (nel > 0) + { + m_data.resize (nel); + octave_idx_type k = 0; + for (const auto& ov : lst) + m_data[k++] = ov; + } +} + octave_value_list::octave_value_list (const std::list& lst) { octave_idx_type n = 0; diff --git a/libinterp/octave-value/ovl.h b/libinterp/octave-value/ovl.h --- a/libinterp/octave-value/ovl.h +++ b/libinterp/octave-value/ovl.h @@ -78,7 +78,8 @@ public: octave_value_list (octave_value_list&& obj) : m_data (std::move (obj.m_data)), m_names (std::move (obj.m_names)) { } - // Concatenation constructor. + // Concatenation constructors. + octave_value_list (const std::list&); octave_value_list (const std::list&); ~octave_value_list (void) = default; diff --git a/libinterp/parse-tree/pt-eval.cc b/libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc +++ b/libinterp/parse-tree/pt-eval.cc @@ -1796,7 +1796,7 @@ namespace octave int len = arg_list->length (); - std::list args; + std::list args; auto p = arg_list->begin (); for (int k = 0; k < len; k++) @@ -1817,18 +1817,20 @@ namespace octave octave_value tmp = evaluate (elt); if (tmp.is_cs_list ()) - args.push_back (tmp.list_value ()); + { + octave_value_list tmp_ovl = tmp.list_value (); + + for (octave_idx_type i = 0; i < tmp_ovl.length (); i++) + args.push_back (tmp_ovl(i)); + } else if (tmp.is_defined ()) args.push_back (tmp); } else - { - args.push_back (octave_value ()); - break; - } + break; } - return args; + return octave_value_list (args); } octave_value_list