Skip to content

Commit

Permalink
return immediately from ht_keyindex if dictionary is empty (JuliaLa…
Browse files Browse the repository at this point in the history
…ng#44341)

Avoids hashing the input key for empty dictionaries.

Inspired by rust-lang/hashbrown#305.
  • Loading branch information
KristofferC committed Feb 25, 2022
1 parent 2e2c16a commit a2e4226
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2e4226

Please sign in to comment.