@@ -43,13 +43,15 @@ void set_binary_op_output_data(
4343 array& out,
4444 BinaryOpType bopt,
4545 bool donate_with_move = false ) {
46+ bool b_donatable = is_donatable (b, out);
47+ bool a_donatable = is_donatable (a, out);
4648 switch (bopt) {
4749 case BinaryOpType::ScalarScalar:
4850 out.set_data (
4951 allocator::malloc_or_wait (out.itemsize ()), 1 , a.strides (), a.flags ());
5052 break ;
5153 case BinaryOpType::ScalarVector:
52- if (b. is_donatable () && b. itemsize () == out. itemsize () ) {
54+ if (b_donatable ) {
5355 if (donate_with_move) {
5456 out.move_shared_buffer (b);
5557 } else {
@@ -64,7 +66,7 @@ void set_binary_op_output_data(
6466 }
6567 break ;
6668 case BinaryOpType::VectorScalar:
67- if (a. is_donatable () && a. itemsize () == out. itemsize () ) {
69+ if (a_donatable ) {
6870 if (donate_with_move) {
6971 out.move_shared_buffer (a);
7072 } else {
@@ -79,13 +81,13 @@ void set_binary_op_output_data(
7981 }
8082 break ;
8183 case BinaryOpType::VectorVector:
82- if (a. is_donatable () && a. itemsize () == out. itemsize () ) {
84+ if (a_donatable ) {
8385 if (donate_with_move) {
8486 out.move_shared_buffer (a);
8587 } else {
8688 out.copy_shared_buffer (a);
8789 }
88- } else if (b. is_donatable () && b. itemsize () == out. itemsize () ) {
90+ } else if (b_donatable ) {
8991 if (donate_with_move) {
9092 out.move_shared_buffer (b);
9193 } else {
@@ -100,16 +102,14 @@ void set_binary_op_output_data(
100102 }
101103 break ;
102104 case BinaryOpType::General:
103- if (a.is_donatable () && a.flags ().row_contiguous &&
104- a.itemsize () == out.itemsize () && a.size () == out.size ()) {
105+ if (a_donatable && a.flags ().row_contiguous && a.size () == out.size ()) {
105106 if (donate_with_move) {
106107 out.move_shared_buffer (a);
107108 } else {
108109 out.copy_shared_buffer (a);
109110 }
110111 } else if (
111- b.is_donatable () && b.flags ().row_contiguous &&
112- b.itemsize () == out.itemsize () && b.size () == out.size ()) {
112+ b_donatable && b.flags ().row_contiguous && b.size () == out.size ()) {
113113 if (donate_with_move) {
114114 out.move_shared_buffer (b);
115115 } else {
0 commit comments