Skip to content

Commit 9e66bc9

Browse files
committed
abs: Make value == ZEND_LONG_MIN an unexpected branch
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.
1 parent 8655352 commit 9e66bc9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ext/standard/math.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ PHP_FUNCTION(abs)
260260

261261
switch (Z_TYPE_P(value)) {
262262
case IS_LONG:
263-
if (Z_LVAL_P(value) == ZEND_LONG_MIN) {
263+
if (UNEXPECTED(Z_LVAL_P(value) == ZEND_LONG_MIN)) {
264264
RETURN_DOUBLE(-(double)ZEND_LONG_MIN);
265265
} else {
266266
RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value));

0 commit comments

Comments
 (0)