Skip to content

Commit fd0848e

Browse files
authored
fix #31760, regression in Dict iterate (#31762)
1 parent 74305bf commit fd0848e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

base/dict.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,17 +662,17 @@ function skip_deleted(h::Dict, i)
662662
return i
663663
end
664664
end
665-
return nothing
665+
return 0
666666
end
667667
function skip_deleted_floor!(h::Dict)
668668
idx = skip_deleted(h, h.idxfloor)
669-
if idx !== nothing
669+
if idx != 0
670670
h.idxfloor = idx
671671
end
672672
idx
673673
end
674674

675-
@propagate_inbounds _iterate(t::Dict{K,V}, i) where {K,V} = i === nothing ? nothing : (Pair{K,V}(t.keys[i],t.vals[i]), i == typemax(Int) ? nothing : i+1)
675+
@propagate_inbounds _iterate(t::Dict{K,V}, i) where {K,V} = i == 0 ? nothing : (Pair{K,V}(t.keys[i],t.vals[i]), i == typemax(Int) ? 0 : i+1)
676676
@propagate_inbounds function iterate(t::Dict)
677677
_iterate(t, skip_deleted_floor!(t))
678678
end
@@ -681,12 +681,12 @@ end
681681
isempty(t::Dict) = (t.count == 0)
682682
length(t::Dict) = t.count
683683

684-
@propagate_inbounds function Base.iterate(v::T, i::Union{Int,Nothing}=v.dict.idxfloor) where T <: Union{KeySet{<:Any, <:Dict}, ValueIterator{<:Dict}}
685-
i === nothing && return nothing # This is to catch nothing returned when i = typemax
684+
@propagate_inbounds function Base.iterate(v::T, i::Int = v.dict.idxfloor) where T <: Union{KeySet{<:Any, <:Dict}, ValueIterator{<:Dict}}
685+
i == 0 && return nothing
686686
i = skip_deleted(v.dict, i)
687-
i === nothing && return nothing # This is to catch nothing returned by skip_deleted
687+
i == 0 && return nothing
688688
vals = T <: KeySet ? v.dict.keys : v.dict.vals
689-
(@inbounds vals[i], i == typemax(Int) ? nothing : i+1)
689+
(@inbounds vals[i], i == typemax(Int) ? 0 : i+1)
690690
end
691691

692692
filter!(f, d::Dict) = filter_in_one_pass!(f, d)

0 commit comments

Comments
 (0)