From 11456bd33ea76d0145370c4ee2b2d1a3b072cd84 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Tue, 24 Sep 2024 14:15:11 +0200 Subject: [PATCH] Remove unneeded Map.has check in hash joins This slightly improves performance. --- join/HashJoin.js | 6 ++++-- join/SymmetricHashJoin.js | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/join/HashJoin.js b/join/HashJoin.js index 6ea664c..63b605f 100644 --- a/join/HashJoin.js +++ b/join/HashJoin.js @@ -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); } } diff --git a/join/SymmetricHashJoin.js b/join/SymmetricHashJoin.js index 57efdaf..6b87176 100644 --- a/join/SymmetricHashJoin.js +++ b/join/SymmetricHashJoin.js @@ -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); }