Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion base/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,18 @@ end

push!(s::Set, x) = (s.dict[x] = nothing; s)

pop!(s::Set, x, default) = (x in s ? pop!(s, x) : default)
function pop!(s::Set, x, default)
dict = s.dict
index = ht_keyindex(dict, x)
if index > 0
@inbounds key = dict.keys[index]
_delete!(dict, index)
return key
else
return default
end
end

function pop!(s::Set, x)
index = ht_keyindex(s.dict, x)
index < 1 && throw(KeyError(x))
Expand Down