From 29e3a004dd0acc8c50bd5ec5d7c75572aacc5cda Mon Sep 17 00:00:00 2001 From: Ambrose Bonnaire-Sergeant Date: Fri, 23 Aug 2024 14:41:14 -0500 Subject: [PATCH] Remove redundant key comparisons in HashCollisionNode Comparing key to array[idx] is redundant as findIndex already performed key comparison to find the index. https://github.com/clojure/clojure/commit/8b4261bc1e377c8a702f2b5538ab728700737b0f --- src/com/ambrosebs/map.clj | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/com/ambrosebs/map.clj b/src/com/ambrosebs/map.clj index 7583010..8433219 100644 --- a/src/com/ambrosebs/map.clj +++ b/src/com/ambrosebs/map.clj @@ -848,29 +848,17 @@ (find-node [this shift hash key] (let [idx (find-index array count key)] - (cond - (< idx 0) + (if (< idx 0) nil - - (= key (aget array idx)) (MapEntry/create (aget array idx) - (aget array (inc idx))) - - :else - nil))) + (aget array (inc idx)))))) (find-node [this shift hash key not-found] (let [idx (find-index array count key)] - (cond - (< idx 0) + (if (< idx 0) not-found - - (= key (aget array idx)) (MapEntry/create (aget array idx) - (aget array (inc idx))) - - :else - not-found))) + (aget array (inc idx)))))) (node-seq [this] (node-seq-create array))