Skip to content

Commit f23980d

Browse files
committed
Optimized bit shifting
1 parent 65ea801 commit f23980d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/random/randomizer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ PHP_METHOD(Random_Randomizer, getBytesFromString)
444444

445445
uint64_t offsets = result.result & mask_repeat;
446446
for (size_t i = 0; i < result.size; i++) {
447-
uint64_t offset = offsets >> (i * 8) & 0xff;
447+
uint64_t offset = offsets & 0xff;
448+
offsets >>= 8;
448449

449450
if (offset > max_offset) {
450451
if (++failures > PHP_RANDOM_RANGE_ATTEMPTS) {

0 commit comments

Comments
 (0)