Skip to content

Commit a97137e

Browse files
authored
Base: append!, resize!: convert length to Int before passing it on (#57585)
Reduces the number of invalidations from 512 to 505 on running this code: ```julia struct I <: Integer end Base.Int(::I) = 7 ```
1 parent d369c10 commit a97137e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

base/array.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ function append! end
13481348

13491349
function append!(a::Vector{T}, items::Union{AbstractVector{<:T},Tuple}) where T
13501350
items isa Tuple && (items = map(x -> convert(T, x), items))
1351-
n = length(items)
1351+
n = Int(length(items))::Int
13521352
_growend!(a, n)
13531353
copyto!(a, length(a)-n+1, items, firstindex(items), n)
13541354
return a
@@ -1472,7 +1472,8 @@ julia> a[1:6]
14721472
1
14731473
```
14741474
"""
1475-
function resize!(a::Vector, nl::Integer)
1475+
function resize!(a::Vector, nl_::Integer)
1476+
nl = Int(nl_)::Int
14761477
l = length(a)
14771478
if nl > l
14781479
_growend!(a, nl-l)

0 commit comments

Comments
 (0)