Skip to content

Commit 159424f

Browse files
Use foreach instead for in array append! (#57752)
Use `foreach` loop instead of `for` loop in array's `append!` due to it being type-stable.
1 parent ff3d28d commit 159424f

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
@@ -1356,7 +1356,7 @@ end
13561356

13571357
append!(a::AbstractVector, iter) = _append!(a, IteratorSize(iter), iter)
13581358
push!(a::AbstractVector, iter...) = append!(a, iter)
1359-
append!(a::AbstractVector, iter...) = (for v in iter; append!(a, v); end; return a)
1359+
append!(a::AbstractVector, iter...) = (foreach(v -> append!(a, v), iter); a)
13601360

13611361
function _append!(a::AbstractVector, ::Union{HasLength,HasShape}, iter)
13621362
n = Int(length(iter))::Int

0 commit comments

Comments
 (0)