Skip to content

Commit adb832a

Browse files
yuyichaotkelman
authored andcommitted
Avoid introducing local variable (and GC frame store) when the inliner is
confused about the return point. (cherry picked from commit bb247cf) ref #13461
1 parent 8b63092 commit adb832a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

base/array.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ end
313313
setindex!{T}(A::Array{T}, x, i1::Real) = arrayset(A, convert(T,x)::T, to_index(i1))
314314
setindex!{T}(A::Array{T}, x, i1::Real, i2::Real, I::Real...) = arrayset(A, convert(T,x)::T, to_index(i1), to_index(i2), to_indexes(I...)...)
315315

316-
unsafe_setindex!{T}(A::Array{T}, x, i1::Real, I::Real...) = @inbounds return arrayset(A, convert(T,x)::T, to_index(i1), to_indexes(I...)...)
316+
# Type inference is confused by `@inbounds return ...` and introduces a
317+
# !ispointerfree local variable and a GC frame
318+
unsafe_setindex!{T}(A::Array{T}, x, i1::Real, I::Real...) =
319+
(@inbounds arrayset(A, convert(T,x)::T, to_index(i1), to_indexes(I...)...); A)
317320

318321
# These are redundant with the abstract fallbacks but needed for bootstrap
319322
function setindex!(A::Array, x, I::AbstractVector{Int})

0 commit comments

Comments
 (0)