Mercurial > hg > octave-nkf
diff src/oct-obj.cc @ 8579:7e0f36dfefbe
implement octave_value_list using Array
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 23 Jan 2009 09:57:19 +0100 |
parents | 3d8a914c580e |
children | 188d38a553c7 |
line wrap: on
line diff
--- a/src/oct-obj.cc +++ b/src/oct-obj.cc @@ -29,32 +29,9 @@ #include "oct-obj.h" #include "Cell.h" -octave_value_list::octave_value_list (const Cell& tc) - : data (tc.numel ()) -{ - for (octave_idx_type i = 0; i < tc.numel (); i++) - data[i] = tc(i); -} - octave_allocator octave_value_list::allocator (sizeof (octave_value_list)); -void -octave_value_list::resize (octave_idx_type n, const octave_value& val) -{ - octave_idx_type len = length (); - - if (n > len) - { - data.resize (n); - - for (octave_idx_type i = len; i < n; i++) - data[i] = val; - } - else if (n < len) - data.resize (n); -} - octave_value_list& octave_value_list::prepend (const octave_value& val) { @@ -247,8 +224,15 @@ octave_value_list::make_storable_values (void) { octave_idx_type len = length (); + const Array<octave_value>& cdata = data; + for (octave_idx_type i = 0; i < len; i++) - data[i].make_storable_value (); + { + // This is optimized so that we don't force a copy unless necessary. + octave_value tmp = cdata(i).storable_value (); + if (! tmp.is_copy_of (cdata (i))) + data(i) = tmp; + } } /*