# HG changeset patch # User Jaroslav Hajek # Date 1259526102 -3600 # Node ID e3bd1569a68c3227a895cdbe9e099388cc0d4725 # Parent cddd5c3d5f04014f0b927938b2ee6dc2f66cbdcc in-place operation of unary ops on temporary expressions diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-11-29 Jaroslav Hajek + + * pt-unop.cc (tree_prefix_expression::rvalue1): Try to use + octave_value::do_non_const_unary_op. + 2009-11-29 Jaroslav Hajek * DLD-FUNCTIONS/urlwrite.cc (curl_handle::init): Use CURLOPT_USERPWD diff --git a/src/pt-unop.cc b/src/pt-unop.cc --- 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 ();