diff src/ov.cc @ 8523:ad3afaaa19c1

implement non-copying contiguous range indexing
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 15 Jan 2009 07:22:24 +0100
parents 445d27d79f4e
children b01fef323c24
line wrap: on
line diff
--- a/src/ov.cc	Thu Jan 15 01:06:06 2009 -0500
+++ b/src/ov.cc	Thu Jan 15 07:22:24 2009 +0100
@@ -1170,7 +1170,7 @@
 {
   if (op == op_asn_eq)
     // Regularize a null matrix if stored into a variable.
-    operator = (rhs.non_null_value ());
+    operator = (rhs.storable_value ());
   else
     {
       // FIXME -- only do the following stuff if we can't find
@@ -1552,18 +1552,23 @@
                                              type_name (), "complex vector"));
 }
 
+// FIXME: This is a good place for pre-storage hooks, but the functions should
+// probably be named differently. These functions will be called
 
 octave_value 
-octave_value::non_null_value (void) const
+octave_value::storable_value (void) const
 {
+  octave_value retval = *this;
   if (is_null_value ())
-    return octave_value (rep->empty_clone ());
+    retval = octave_value (rep->empty_clone ());
   else
-    return *this;
+    retval.maybe_economize ();
+
+  return retval;
 }
 
 void 
-octave_value::make_non_null_value (void) 
+octave_value::make_storable_value (void) 
 {
   if (is_null_value ())
     {
@@ -1572,6 +1577,8 @@
         delete rep;
       rep = rc;
     }
+  else
+    maybe_economize ();
 }
 
 int