diff src/ov-cell.cc @ 8679:280fae940bb0

optimize scalar indexing
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 05 Feb 2009 13:58:11 +0100
parents 1dce30ab0e72
children a669df7beb73
line wrap: on
line diff
--- a/src/ov-cell.cc	Wed Feb 04 16:05:01 2009 +0100
+++ b/src/ov-cell.cc	Thu Feb 05 13:58:11 2009 +0100
@@ -55,6 +55,42 @@
 #include "ls-hdf5.h"
 #include "ls-utils.h"
 
+// Cell is able to handle octave_value indexing by itself, so just forward
+// everything.
+
+template <>
+octave_value
+octave_base_matrix<Cell>::do_index_op (const octave_value_list& idx,
+                                       bool resize_ok)
+{
+  return matrix.index (idx, resize_ok);
+}
+
+template <>
+void
+octave_base_matrix<Cell>::assign (const octave_value_list& idx, const Cell& rhs)
+{
+  matrix.assign (idx, rhs);
+}
+
+template <>
+void
+octave_base_matrix<Cell>::assign (const octave_value_list& idx, octave_value rhs)
+{
+  // FIXME: Really?
+  if (rhs.is_cell ())
+    matrix.assign (idx, rhs.cell_value ());
+  else
+    matrix.assign (idx, Cell (rhs));
+}
+
+template <>
+void
+octave_base_matrix<Cell>::delete_elements (const octave_value_list& idx)
+{
+  matrix.delete_elements (idx);
+}
+
 template class octave_base_matrix<Cell>;
 
 DEFINE_OCTAVE_ALLOCATOR (octave_cell);
@@ -340,15 +376,6 @@
   return retval;
 }
 
-void
-octave_cell::assign (const octave_value_list& idx, const octave_value& rhs)
-{
-  if (rhs.is_cell ())
-    octave_base_matrix<Cell>::assign (idx, rhs.cell_value ());
-  else
-    octave_base_matrix<Cell>::assign (idx, Cell (rhs));
-}
-
 size_t
 octave_cell::byte_size (void) const
 {