Skip to content

Commit 0d419cc

Browse files
committed
Optimized bit shifting
1 parent cc6e295 commit 0d419cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/random/randomizer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@ PHP_METHOD(Random_Randomizer, getBytes)
298298
zend_string_free(retval);
299299
RETURN_THROWS();
300300
}
301+
uint64_t tmp_ret = result.result;
301302
for (size_t i = 0; i < result.size; i++) {
302-
ZSTR_VAL(retval)[total_size++] = (result.result >> (i * 8)) & 0xff;
303+
ZSTR_VAL(retval)[total_size++] = tmp_ret & 0xff;
304+
tmp_ret >>= 8;
303305
if (total_size >= length) {
304306
break;
305307
}

0 commit comments

Comments
 (0)