Mercurial > hg > octave-terminal
changeset 8463:a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 12 Jan 2009 12:31:11 -0500 |
parents | ebdf1e058d85 |
children | cb48e594a441 |
files | src/ChangeLog src/strfns.cc |
diffstat | 2 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-01-12 John W. Eaton <jwe@octave.org> + + * strfns.cc (Fstrvcat, Fchar): Use queue to avoid duplicate calls + to all_strings. + 2009-01-12 Thorsten Meyer <thorsten.meyier@gmx.de> * strfns.cc (Fstrvcap): New function.
--- a/src/strfns.cc +++ b/src/strfns.cc @@ -27,6 +27,7 @@ #include <cctype> +#include <queue> #include <sstream> #include "dMatrix.h" @@ -80,6 +81,8 @@ int max_len = 0; + std::queue<string_vector> args_as_strings; + for (int i = 0; i < nargin; i++) { string_vector s = args(i).all_strings (); @@ -99,6 +102,8 @@ if (s_max_len > max_len) max_len = s_max_len; + + args_as_strings.push (s); } string_vector result (n_elts); @@ -107,7 +112,7 @@ for (int i = 0; i < nargin; i++) { - string_vector s = args(i).all_strings (); + string_vector s = args_as_strings.pop (); int n = s.length (); @@ -125,9 +130,7 @@ } } else - { - result[k++] = std::string (max_len, ' '); - } + result[k++] = std::string (max_len, ' '); } retval = octave_value (result, '\''); @@ -190,6 +193,8 @@ int max_len = 0; + std::queue<string_vector> args_as_strings; + for (int i = 0; i < nargin; i++) { string_vector s = args(i).all_strings (); @@ -216,6 +221,8 @@ if (s_max_len > max_len) max_len = s_max_len; + + args_as_strings.push (s); } string_vector result (n_elts); @@ -224,7 +231,7 @@ for (int i = 0; i < nargin; i++) { - string_vector s = args(i).all_strings (); + string_vector s = args_as_strings.pop (); int n = s.length ();