Skip to content

Commit

Permalink
zend_ulong_ntz/zend_ulong_ntz little optimisation for windows.
Browse files Browse the repository at this point in the history
because of the unix code path, UB is avoided beforehand thus errors
with 0 mask for the windows api is unlikely.
  • Loading branch information
devnexen committed Jan 19, 2025
1 parent 9283abc commit 106783a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Zend/zend_bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ ZEND_ATTRIBUTE_CONST static zend_always_inline int zend_ulong_ntz(zend_ulong num
unsigned long index;

#if defined(_WIN64)
if (!BitScanForward64(&index, num)) {
if (UNEXPECTED(!BitScanForward64(&index, num))) {
#else
if (!BitScanForward(&index, num)) {
if (UNEXPECTED(!BitScanForward(&index, num))) {
#endif
/* undefined behavior */
return SIZEOF_ZEND_LONG * 8;
Expand Down Expand Up @@ -94,9 +94,9 @@ ZEND_ATTRIBUTE_CONST static zend_always_inline int zend_ulong_nlz(zend_ulong num
unsigned long index;

#if defined(_WIN64)
if (!BitScanReverse64(&index, num)) {
if (UNEXPECTED(!BitScanReverse64(&index, num))) {
#else
if (!BitScanReverse(&index, num)) {
if (UNEXPECTED(!BitScanReverse(&index, num))) {
#endif
/* undefined behavior */
return SIZEOF_ZEND_LONG * 8;
Expand Down

0 comments on commit 106783a

Please sign in to comment.