Mercurial > octave
changeset 31317:83e47ccf34ac
Avoid function chains in more files.
Remove more function chains as identified by grep.
Use const auto& tmp as intermediate variables.
See https://octave.discourse.group/t/3433 for details.
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Mon, 17 Oct 2022 19:11:16 -0400 |
parents | 24e45a79bf3c |
children | eba9d6d4cc41 |
files | libinterp/operators/op-cs-scm.cc libinterp/operators/op-fcm-fcm.cc libinterp/operators/op-s-m.cc |
diffstat | 3 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/operators/op-cs-scm.cc Mon Oct 17 16:11:02 2022 -0400 +++ b/libinterp/operators/op-cs-scm.cc Mon Oct 17 19:11:16 2022 -0400 @@ -81,7 +81,10 @@ const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2); - return octave_value (v2.sparse_complex_matrix_value () / v1.complex_value ()); + const auto& tmp1 = v1.complex_value (); + const auto& tmp2 = v2.sparse_complex_matrix_value (); + const auto& tmp3 = tmp2 / tmp1; + return octave_value (tmp3); } DEFBINOP_FN (lt, complex, sparse_complex_matrix, mx_el_lt) @@ -102,7 +105,10 @@ const octave_sparse_complex_matrix& v2 = dynamic_cast<const octave_sparse_complex_matrix&> (a2); - return octave_value (v2.sparse_complex_matrix_value () / v1.complex_value ()); + const auto& tmp1 = v1.complex_value (); + const auto& tmp2 = v2.sparse_complex_matrix_value (); + const auto& tmp3 = tmp2 / tmp1; + return octave_value (tmp3); } DEFBINOP_FN (el_and, complex, sparse_complex_matrix, mx_el_and)
--- a/libinterp/operators/op-fcm-fcm.cc Mon Oct 17 16:11:02 2022 -0400 +++ b/libinterp/operators/op-fcm-fcm.cc Mon Oct 17 19:11:16 2022 -0400 @@ -54,7 +54,9 @@ if (v.ndims () > 2) error ("transpose not defined for N-D objects"); - return octave_value (v.float_complex_matrix_value ().transpose ()); + const auto& tmp = v.float_complex_matrix_value (); + const auto& tmp2 = tmp.transpose (); + return octave_value (tmp2); } DEFUNOP (hermitian, float_complex_matrix) @@ -65,7 +67,9 @@ if (v.ndims () > 2) error ("complex-conjugate transpose not defined for N-D objects"); - return octave_value (v.float_complex_matrix_value ().hermitian ()); + const auto& tmp = v.float_complex_matrix_value (); + const auto& tmp2 = tmp.hermitian (); + return octave_value (tmp2); } DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
--- a/libinterp/operators/op-s-m.cc Mon Oct 17 16:11:02 2022 -0400 +++ b/libinterp/operators/op-s-m.cc Mon Oct 17 19:11:16 2022 -0400 @@ -68,7 +68,10 @@ const octave_scalar& v1 = dynamic_cast<const octave_scalar&> (a1); const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); - return octave_value (v2.array_value () / v1.double_value ()); + const auto& tmp1 = v1.double_value (); + const auto& tmp2 = v2.array_value (); + const auto& tmp3 = tmp2 / tmp1; + return octave_value (tmp3); } DEFNDBINOP_FN (lt, scalar, matrix, scalar, array, mx_el_lt) @@ -87,7 +90,10 @@ const octave_scalar& v1 = dynamic_cast<const octave_scalar&> (a1); const octave_matrix& v2 = dynamic_cast<const octave_matrix&> (a2); - return octave_value (v2.array_value () / v1.double_value ()); + const auto& tmp1 = v1.double_value (); + const auto& tmp2 = v2.array_value (); + const auto& tmp3 = tmp2 / tmp1; + return octave_value (tmp3); } DEFNDBINOP_FN (el_and, scalar, matrix, scalar, array, mx_el_and)