Skip to content

Commit 04d9229

Browse files
authored
mark these methods as eligible for the faster cache for novel lookups (#36765)
1 parent f8defa4 commit 04d9229

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

base/dict.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ end
367367
# > 3/4 deleted or > 2/3 full
368368
rehash!(h, h.count > 64000 ? h.count*2 : h.count*4)
369369
end
370+
nothing
370371
end
371372

372373
function setindex!(h::Dict{K,V}, v0, key0) where V where K
@@ -392,6 +393,22 @@ function setindex!(h::Dict{K,V}, v0, key::K) where V where K
392393
return h
393394
end
394395

396+
function setindex!(h::Dict{K,Any}, v, key::K) where K
397+
@nospecialize v
398+
index = ht_keyindex2!(h, key)
399+
400+
if index > 0
401+
h.age += 1
402+
@inbounds h.keys[index] = key
403+
@inbounds h.vals[index] = v
404+
else
405+
@inbounds _setindex!(h, v, key, -index)
406+
end
407+
408+
return h
409+
end
410+
411+
395412
"""
396413
get!(collection, key, default)
397414

base/essentials.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ See also: [`round`](@ref), [`trunc`](@ref), [`oftype`](@ref), [`reinterpret`](@r
210210
"""
211211
function convert end
212212

213-
convert(::Type{Union{}}, x) = throw(MethodError(convert, (Union{}, x)))
214-
convert(::Type{Any}, x) = x
213+
convert(::Type{Union{}}, @nospecialize x) = throw(MethodError(convert, (Union{}, x)))
214+
convert(::Type{Any}, @nospecialize x) = x
215215
convert(::Type{T}, x::T) where {T} = x
216216
convert(::Type{Type}, x::Type) = x # the ssair optimizer is strongly dependent on this method existing to avoid over-specialization
217217
# in the absence of inlining-enabled

0 commit comments

Comments
 (0)