From afeb2be6b58902f61e4857a7abe5442752564055 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 25 Feb 2022 19:06:42 +0100 Subject: [PATCH] return immediately from `ht_keyindex` if dictionary is empty (#44341) Avoids hashing the input key for empty dictionaries. Inspired by rust-lang/hashbrown#305. --- base/dict.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/base/dict.jl b/base/dict.jl index dabdfa5c347732..53f760999482f0 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -278,6 +278,7 @@ end # get the index where a key is stored, or -1 if not present function ht_keyindex(h::Dict{K,V}, key) where V where K + isempty(h) && return -1 sz = length(h.keys) iter = 0 maxprobe = h.maxprobe