Mercurial > hg > octave-terminal
changeset 10939:c07cb4ef80db
optimize [a{:}] when a{i} are all scalars
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 01 Sep 2010 13:40:58 +0200 |
parents | 300636502235 |
children | 306e40d773a9 |
files | src/ChangeLog src/pt-mat.cc |
diffstat | 2 files changed, 19 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-09-01 Jaroslav Hajek <highegg@gmail.com> + + * pt-mat.cc (single_type_concat (Array<T>&, ...)): Optimize all + scalars case. + 2010-09-01 Jaroslav Hajek <highegg@gmail.com> * oct-map.cc (octave_map::cat): Search first for an index with
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -690,8 +690,21 @@ { // If possible, forward the operation to liboctave. // Single row. - // FIXME: optimize all scalars case. tm_row_const& row = tmp.front (); + if (! (equal_types<T, char>::value || equal_types<T, octave_value>::value) + && row.all_1x1_p ()) + { + // Optimize all scalars case. + result.clear (dv); + assert (result.numel () == row.length ()); + octave_idx_type i = 0; + for (tm_row_const::iterator q = row.begin (); + q != row.end () && ! error_state; q++) + result(i++) = octave_value_extract<T> (*q); + + return; + } + octave_idx_type ncols = row.length (), i = 0; OCTAVE_LOCAL_BUFFER (Array<T>, array_list, ncols);