mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/gmp: Refactor op overloading for ZEND_BW_NOT
The only way for the do_operation object handler to be called for unary operations is when the zval is an object. Therefore we know we have a zval of the correct type and there is no need to check for it.
This commit is contained in:
parent
7e1d035077
commit
313886e22b
1 changed files with 3 additions and 5 deletions
|
@ -404,7 +404,7 @@ valueof_op_failure:
|
|||
|
||||
static zend_result gmp_do_operation_ex(uint8_t opcode, zval *result, zval *op1, zval *op2) /* {{{ */
|
||||
{
|
||||
mpz_ptr gmp_op1, gmp_result;
|
||||
mpz_ptr gmp_result;
|
||||
switch (opcode) {
|
||||
case ZEND_ADD:
|
||||
return binop_operator_helper(mpz_add, result, op1, op2);
|
||||
|
@ -429,11 +429,9 @@ static zend_result gmp_do_operation_ex(uint8_t opcode, zval *result, zval *op1,
|
|||
case ZEND_BW_XOR:
|
||||
return binop_operator_helper(mpz_xor, result, op1, op2);
|
||||
case ZEND_BW_NOT: {
|
||||
if (!gmp_zend_parse_arg_into_mpz_ex(op1, &gmp_op1, 1, false)) {
|
||||
return FAILURE;
|
||||
}
|
||||
ZEND_ASSERT(Z_TYPE_P(op1) == IS_OBJECT && Z_OBJCE_P(op1) == gmp_ce);
|
||||
gmp_create(result, &gmp_result);
|
||||
mpz_com(gmp_result, gmp_op1);
|
||||
mpz_com(gmp_result, GET_GMP_FROM_ZVAL(op1));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue