Skip to content

Commit 6175761

Browse files
authored
Remove unnecessary @inbounds in fill! (#59174)
LLVM can elide this and our effect analysis doesn't know that the `@inbounds` is safe here. ```julia-repl julia> function my_fill(x,y) v = Vector{typeof(x)}(undef, y) for i in eachindex(v) v[i] = y end v end my_fill (generic function with 1 method) julia> Base.infer_effects(fill, Tuple{Int, Int}) (!c,+e,!n,!t,+s,+m,!u,+o,+r) julia> Base.infer_effects(my_fill, Tuple{Int, Int}) (!c,+e,!n,!t,+s,+m,+u,+o,+r) julia> @b fill(10, 10) 12.152 ns (2 allocs: 144 bytes) julia> @b fill(10, 10) 12.179 ns (2 allocs: 144 bytes) julia> @b fill(10, 10) 12.187 ns (2 allocs: 144 bytes) julia> @b my_fill(10, 10) 11.806 ns (2 allocs: 144 bytes) julia> @b my_fill(10, 10) 12.152 ns (2 allocs: 144 bytes) julia> @b my_fill(10, 10) 12.190 ns (2 allocs: 144 bytes) ```
1 parent 3de5b9a commit 6175761

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

base/array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function fill!(dest::Array{T}, x) where T
336336
end
337337
function _fill!(dest::Array{T}, x::T) where T
338338
for i in eachindex(dest)
339-
@inbounds dest[i] = x
339+
dest[i] = x
340340
end
341341
return dest
342342
end

0 commit comments

Comments
 (0)