Skip to content

Commit

Permalink
Remove unneeded Map.has check in hash joins
Browse files Browse the repository at this point in the history
This slightly improves performance.
  • Loading branch information
rubensworks committed Sep 24, 2024
1 parent bfaaf7f commit 11456bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions join/HashJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ class HashJoin extends AsyncIterator
function addItem(item)
{
let hash = this.funHash(item);
if (!this.leftMap.has(hash))
this.leftMap.set(hash, []);
let arr = this.leftMap.get(hash);
if (!arr) {
arr = [];
this.leftMap.set(hash, arr);
}
arr.push(item);
}
}
Expand Down
4 changes: 4 additions & 0 deletions join/SymmetricHashJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class SymmetricHashJoin extends AsyncIterator
if (!map.has(hash))
map.set(hash, []);
let arr = map.get(hash);
if (!arr) {
arr = [];
map.set(hash, arr);
}
arr.push(item);
}

Expand Down

0 comments on commit 11456bd

Please sign in to comment.