* try eliding a binary op, if commutative is true also try swapped arguments */
| 337 | * try eliding a binary op, if commutative is true also try swapped arguments |
| 338 | */ |
| 339 | NPY_NO_EXPORT int |
| 340 | try_binary_elide(PyObject * m1, PyObject * m2, |
| 341 | PyObject * (inplace_op)(PyArrayObject * m1, PyObject * m2), |
| 342 | PyObject ** res, int commutative) |
| 343 | { |
| 344 | /* set when no elision can be done independent of argument order */ |
| 345 | int cannot = 0; |
| 346 | if (can_elide_temp(m1, m2, &cannot)) { |
| 347 | *res = inplace_op((PyArrayObject *)m1, m2); |
| 348 | #if NPY_ELIDE_DEBUG != 0 |
| 349 | puts("elided temporary in binary op"); |
| 350 | #endif |
| 351 | return 1; |
| 352 | } |
| 353 | else if (commutative && !cannot) { |
| 354 | if (can_elide_temp(m2, m1, &cannot)) { |
| 355 | *res = inplace_op((PyArrayObject *)m2, m1); |
| 356 | #if NPY_ELIDE_DEBUG != 0 |
| 357 | puts("elided temporary in commutative binary op"); |
| 358 | #endif |
| 359 | return 1; |
| 360 | } |
| 361 | } |
| 362 | *res = NULL; |
| 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | /* try elide unary temporary */ |
| 367 | NPY_NO_EXPORT int |
no test coverage detected