Skip to content

Commit

Permalink
return immediately from ht_keyindex if dictionary is empty (#44341)
Browse files Browse the repository at this point in the history
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

5 comments on commit a2e4226

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@vtjnash
Copy link
Member

@vtjnash vtjnash commented on a2e4226 Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash
Copy link
Member

@vtjnash vtjnash commented on a2e4226 Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CartesianIndex simd seems to have doubled in speed?

Please sign in to comment.