8000 Fix slow iterator for Set (#1333) · lisongyu/immutable-js@b9dabc1 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9dabc1

Browse files
authored
Fix slow iterator for Set (immutable-js#1333)
Replace's Set's internal representation of Map<V, true> to Map<V, V>, which more closely mirrors Set's own representation of presenting keys and values as the same value. Fixes immutable-js#1249
1 parent bdb071d commit b9dabc1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Set.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class Set extends SetCollection {
6464
// @pragma Modification
6565

6666
add(value) {
67-
return updateSet(this, this._map.set(value, true));
67+
return updateSet(this, this._map.set(value, value));
6868
}
6969

7070
remove(value) {
@@ -150,11 +150,11 @@ export class Set extends SetCollection {
150150
}
151151

152152
__iterate(fn, reverse) {
153-
return this._map.__iterate((_, k) => fn(k, k, this), reverse);
153+
return this._map.__iterate(k => fn(k, k, this), reverse);
154154
}
155155

156156
__iterator(type, reverse) {
157-
return this._map.map((_, k) => k).__iterator(type, reverse);
157+
return this._map.__iterator(type, reverse);
158158
}
159159

1601 39F0 60
__ensureOwner(ownerID) {

0 commit comments

Comments
 (0)
0