changeset 8992:d12f44a5dce3

implement fast octave_value constructor
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 17 Mar 2009 21:38:12 +0100
parents c235a59d30a4
children 6769599e3458
files src/ChangeLog src/ov.cc src/ov.h
diffstat 3 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Mar 17 13:43:09 2009 +0100
+++ b/src/ChangeLog	Tue Mar 17 21:38:12 2009 +0100
@@ -1,3 +1,9 @@
+2009-03-17  Jaroslav Hajek  <highegg@gmail.com>
+
+	* ov.cc (octave_value::octave_value): Move to ov.h
+	* ov.h (octave_value::octave_value): Implement fast inline constructor
+	using a static rep.
+
 2009-03-15  Jaroslav Hajek  <highegg@gmail.com>
 
 	* DLD-FUNCTIONS/cellfun.cc (Fcellslices): New DLD function.
--- a/src/ov.cc	Tue Mar 17 13:43:09 2009 +0100
+++ b/src/ov.cc	Tue Mar 17 21:38:12 2009 +0100
@@ -474,11 +474,6 @@
   return retval;
 }
 
-octave_value::octave_value (void)
-  : rep (new octave_base_value ())
-{
-}
-
 octave_value::octave_value (short int i)
   : rep (new octave_scalar (i))
 {
--- a/src/ov.h	Tue Mar 17 13:43:09 2009 +0100
+++ b/src/ov.h	Tue Mar 17 21:38:12 2009 +0100
@@ -156,7 +156,13 @@
 
   enum magic_colon { magic_colon_t };
 
-  octave_value (void);
+  octave_value (void)
+    {
+      static octave_base_value nil_rep;
+      rep = &nil_rep;
+      rep->count++;
+    }
+
   octave_value (short int i);
   octave_value (unsigned short int i);
   octave_value (int i);