Mercurial > octave-antonio
diff src/pt-eval.cc @ 8679:280fae940bb0
optimize scalar indexing
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 05 Feb 2009 13:58:11 +0100 |
parents | 095ae5e0a831 |
children | 5a6db6bd1a02 |
line wrap: on
line diff
--- a/src/pt-eval.cc Wed Feb 04 16:05:01 2009 +0100 +++ b/src/pt-eval.cc Thu Feb 05 13:58:11 2009 +0100 @@ -335,7 +335,7 @@ dim_vector dv = rhs.dims ().redim (2); - octave_idx_type steps = dv(1); + octave_idx_type nrows = dv(0), steps = dv(1); if (steps > 0) { @@ -343,14 +343,25 @@ if (rhs.ndims () > 2) arg = arg.reshape (dv); - //octave_value_list idx(2, octave_value ()); - octave_value_list idx(2, octave_value ()); - idx(0) = octave_value::magic_colon_t; + // for row vectors, use single index to speed things up. + octave_value_list idx; + octave_idx_type iidx; + if (nrows == 1) + { + idx.resize (1); + iidx = 0; + } + else + { + idx.resize (2); + idx(0) = octave_value::magic_colon_t; + iidx = 1; + } for (octave_idx_type i = 1; i <= steps; i++) { // do_index_op expects one-based indices. - idx(1) = i; + idx(iidx) = i; octave_value val = arg.do_index_op (idx); DO_SIMPLE_FOR_LOOP_ONCE (val);