Skip to content
This repository was archived by the owner on Apr 14, 2019. It is now read-only.

Commit e3fd241

Browse files
committed
performance optimization for set methods(union/except/intersect/distinct). avoid double search hash.
1 parent 8507902 commit e3fd241

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

linq.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,7 @@
16061606
function () {
16071607
while (enumerator.moveNext()) {
16081608
var current = enumerator.current();
1609-
if (!keys.contains(current)) {
1610-
keys.add(current);
1609+
if (keys.add(current)) {
16111610
return this.yieldReturn(current);
16121611
}
16131612
}
@@ -1639,8 +1638,7 @@
16391638
function () {
16401639
while (enumerator.moveNext()) {
16411640
var current = enumerator.current();
1642-
if (!outs.contains(current) && keys.contains(current)) {
1643-
outs.add(current);
1641+
if (keys.contains(current) && outs.add(current)) {
16441642
return this.yieldReturn(current);
16451643
}
16461644
}
@@ -1697,17 +1695,15 @@
16971695
if (secondEnumerator === undefined) {
16981696
while (firstEnumerator.moveNext()) {
16991697
current = firstEnumerator.current();
1700-
if (!keys.contains(current)) {
1701-
keys.add(current);
1698+
if (keys.add(current)) {
17021699
return this.yieldReturn(current);
17031700
}
17041701
}
17051702
secondEnumerator = Enumerable.from(second).getEnumerator();
17061703
}
17071704
while (secondEnumerator.moveNext()) {
17081705
current = secondEnumerator.current();
1709-
if (!keys.contains(current)) {
1710-
keys.add(current);
1706+
if (keys.add(current)) {
17111707
return this.yieldReturn(current);
17121708
}
17131709
}

0 commit comments

Comments
 (0)