Skip to content

Commit

Permalink
Comment on what in! does
Browse files Browse the repository at this point in the history
  • Loading branch information
petvana committed May 3, 2022
1 parent d3ff474 commit 709daeb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ isempty(s::Set) = isempty(s.dict)
length(s::Set) = length(s.dict)
in(x, s::Set) = haskey(s.dict, x)

# This avoids hashing and probing twice and it works the same as
# in!(x, s::Set) = in(x, s) ? true : (push!(s, x); false)
function in!(x, s::Set)
idx, sh = ht_keyindex2_shorthash!(s.dict, x)
idx > 0 && return true
Expand Down

0 comments on commit 709daeb

Please sign in to comment.