File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -275,11 +275,14 @@ private function doCountBin()
275
275
}
276
276
277
277
$ ord = \ord ($ bitset [$ bytePos ]);
278
- for ($ bitPos = 0 ; $ bitPos < 8 ; ++$ bitPos ) {
279
- if ($ ord & (1 << $ bitPos )) {
280
- ++$ count ;
281
- }
282
- }
278
+ if ($ ord & 0b00000001 ) ++$ count ;
279
+ if ($ ord & 0b00000010 ) ++$ count ;
280
+ if ($ ord & 0b00000100 ) ++$ count ;
281
+ if ($ ord & 0b00001000 ) ++$ count ;
282
+ if ($ ord & 0b00010000 ) ++$ count ;
283
+ if ($ ord & 0b00100000 ) ++$ count ;
284
+ if ($ ord & 0b01000000 ) ++$ count ;
285
+ if ($ ord & 0b10000000 ) ++$ count ;
283
286
}
284
287
return $ count ;
285
288
}
@@ -305,8 +308,8 @@ private function doCountInt()
305
308
}
306
309
307
310
// iterate byte by byte and count set bits
308
- for ( $ i = 0 ; $ i < \PHP_INT_SIZE ; ++ $ i ) {
309
- $ bitPos = $ i * 8 ;
311
+ $ phpIntBitSize = \PHP_INT_SIZE * 8 ;
312
+ for ( $ bitPos = 0 ; $ bitPos < $ phpIntBitSize ; $ bitPos += 8 ) {
310
313
$ bitChk = 0xff << $ bitPos ;
311
314
$ byte = $ bitset & $ bitChk ;
312
315
if ($ byte ) {
You can’t perform that action at this time.
0 commit comments