Mercurial > hg > octave-lyh
diff src/pt-unop.cc @ 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 | d33a318c1de4 |
children | cd96d29c5efa |
line wrap: on
line diff
--- 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 ();