File tree 3 files changed +1781
-883
lines changed
3 files changed +1781
-883
lines changed Original file line number Diff line number Diff line change @@ -194,16 +194,33 @@ FastBitSet.prototype.forEach = function (fnc) {
194
194
} ;
195
195
196
196
// Returns an iterator of set bit locations (values)
197
- FastBitSet . prototype [ Symbol . iterator ] = function * ( ) {
197
+ FastBitSet . prototype [ Symbol . iterator ] = function ( ) {
198
198
const c = this . words . length ;
199
- for ( let k = 0 ; k < c ; ++ k ) {
200
- let w = this . words [ k ] ;
201
- while ( w != 0 ) {
202
- const t = w & - w ;
203
- yield ( k << 5 ) + this . hammingWeight ( ( t - 1 ) | 0 ) ;
204
- w ^= t ;
205
- }
206
- }
199
+ let k = 0 ;
200
+ let w = this . words [ k ] ;
201
+ let hw = this . hammingWeight
202
+ let words = this . words
203
+ return {
204
+ [ Symbol . iterator ] ( ) {
205
+ return this ;
206
+ } ,
207
+ next ( ) {
208
+ while ( k < c ) {
209
+ if ( w !== 0 ) {
210
+ const t = w & - w ;
211
+ const value = ( k << 5 ) + hw ( ( t - 1 ) | 0 ) ;
212
+ w ^= t ;
213
+ return { done : false , value } ;
214
+ } else {
215
+ k ++ ;
216
+ if ( k < c ) {
217
+ w = words [ k ] ;
218
+ }
219
+ }
220
+ }
221
+ return { done : true , value : undefined } ;
222
+ } ,
223
+ } ;
207
224
} ;
208
225
209
226
// Creates a copy of this bitmap
You can’t perform that action at this time.
0 commit comments