Skip to content

Commit

Permalink
abs: Make value == ZEND_LONG_MIN an unexpected branch
Browse files Browse the repository at this point in the history
As suggested in GH-12286. This results in slightly better assembly in clang,
because the expected case will be handled by a forward jump that is not taken.
  • Loading branch information
TimWolla committed Sep 24, 2023
1 parent 8655352 commit 9e66bc9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/standard/math.c
Expand Up @@ -260,7 +260,7 @@ PHP_FUNCTION(abs)

switch (Z_TYPE_P(value)) {
case IS_LONG:
if (Z_LVAL_P(value) == ZEND_LONG_MIN) {
if (UNEXPECTED(Z_LVAL_P(value) == ZEND_LONG_MIN)) {
RETURN_DOUBLE(-(double)ZEND_LONG_MIN);
} else {
RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value));
Expand Down

0 comments on commit 9e66bc9

Please sign in to comment.