File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -187,16 +187,21 @@ public function valid()
187
187
*/
188
188
public function count ()
189
189
{
190
- $ cnt = 0 ;
191
- $ ord = 0 ;
190
+ $ count = 0 ;
191
+ $ byteLen = strlen ($ this ->bitset );
192
+ for ($ bytePos = 0 ; $ bytePos < $ byteLen ; ++$ bytePos ) {
193
+ if ($ this ->bitset [$ bytePos ] === "\0" ) {
194
+ continue ; // fast skip null byte
195
+ }
192
196
193
- while ($ ord !== $ this ->ordinalMax ) {
194
- if ($ this ->getBit ($ ord ++)) {
195
- ++$ cnt ;
197
+ for ($ bitPos = 0 ; $ bitPos < 8 ; ++$ bitPos ) {
198
+ if ((ord ($ this ->bitset [$ bytePos ]) & (1 << $ bitPos )) !== 0 ) {
199
+ ++$ count ;
200
+ }
196
201
}
197
202
}
198
203
199
- return $ cnt ;
204
+ return $ count ;
200
205
}
201
206
202
207
/**
@@ -249,7 +254,7 @@ public function getOrdinals()
249
254
$ ordinals = array ();
250
255
$ byteLen = strlen ($ this ->bitset );
251
256
252
- for ($ bytePos = 0 ; $ bytePos < $ byteLen ; ++$ bytePos ) {
257
+ for ($ bytePos = 0 ; $ bytePos < $ byteLen ; ++$ bytePos ) {
253
258
if ($ this ->bitset [$ bytePos ] === "\0" ) {
254
259
continue ; // fast skip null byte
255
260
}
You can’t perform that action at this time.
0 commit comments