Mercurial > hg > octave-nkf
changeset 9887:e3bd1569a68c
in-place operation of unary ops on temporary expressions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 29 Nov 2009 21:21:42 +0100 |
parents | cddd5c3d5f04 |
children | cee6c63cff32 |
files | src/ChangeLog src/pt-unop.cc |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-11-29 Jaroslav Hajek <highegg@gmail.com> + + * pt-unop.cc (tree_prefix_expression::rvalue1): Try to use + octave_value::do_non_const_unary_op. + 2009-11-29 Jaroslav Hajek <highegg@gmail.com> * DLD-FUNCTIONS/urlwrite.cc (curl_handle::init): Use CURLOPT_USERPWD
--- a/src/pt-unop.cc +++ b/src/pt-unop.cc @@ -89,7 +89,12 @@ if (! error_state && val.is_defined ()) { - retval = ::do_unary_op (etype, val); + // Attempt to do the operation in-place if it is unshared + // (a temporary expression). + if (val.get_count () == 1) + retval = val.do_non_const_unary_op (etype); + else + retval = ::do_unary_op (etype, val); if (error_state) retval = octave_value ();