Skip to content

Commit 0ba4e71

Browse files
authored
Faster iterator for (almost) empty Dict (#44411)
1 parent 748e320 commit 0ba4e71

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/dict.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mutable struct Dict{K,V} <: AbstractDict{K,V}
8888

8989
function Dict{K,V}() where V where K
9090
n = 16
91-
new(zeros(UInt8,n), Vector{K}(undef, n), Vector{V}(undef, n), 0, 0, 0, 1, 0)
91+
new(zeros(UInt8,n), Vector{K}(undef, n), Vector{V}(undef, n), 0, 0, 0, n, 0)
9292
end
9393
function Dict{K,V}(d::Dict{K,V}) where V where K
9494
new(copy(d.slots), copy(d.keys), copy(d.vals), d.ndel, d.count, d.age,
@@ -274,7 +274,7 @@ function empty!(h::Dict{K,V}) where V where K
274274
h.ndel = 0
275275
h.count = 0
276276
h.age += 1
277-
h.idxfloor = 1
277+
h.idxfloor = sz
278278
return h
279279
end
280280

0 commit comments

Comments
 (0)