diff src/ov-cell.cc @ 9370:4ff6f8efdda2

fix slow cellstr -> char matrix conversions
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 22 Jun 2009 08:59:38 +0200
parents 650c7efa7234
children ea88eece12f5
line wrap: on
line diff
--- a/src/ov-cell.cc
+++ b/src/ov-cell.cc
@@ -29,6 +29,7 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
+#include <queue>
 
 #include "Array-util.h"
 #include "byte-swap.h"
@@ -572,6 +573,8 @@
 
   octave_idx_type max_len = 0;
 
+  std::queue<string_vector> strvec_queue;
+
   for (octave_idx_type i = 0; i < nel; i++)
     {
       string_vector s = matrix(i).all_strings ();
@@ -587,15 +590,18 @@
 
       if (s_max_len > max_len)
 	max_len = s_max_len;
+
+      strvec_queue.push (s);
     }
 
-  retval.resize (n_elts);
+  retval = string_vector (n_elts);
 
   octave_idx_type k = 0;
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
-      string_vector s = matrix(i).all_strings ();
+      const string_vector s = strvec_queue.front ();
+      strvec_queue.pop ();
 
       octave_idx_type s_len = s.length ();