From d973c642ba9dc0b595be6ec44459b9679541c8ba Mon Sep 17 00:00:00 2001 From: "Zachary P. Christensen" Date: Sun, 13 Sep 2020 22:21:00 -0400 Subject: [PATCH] Ensure SIMD happens --- src/ArrayInterface.jl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ArrayInterface.jl b/src/ArrayInterface.jl index fb55a04b6..170da63bb 100644 --- a/src/ArrayInterface.jl +++ b/src/ArrayInterface.jl @@ -551,14 +551,12 @@ Return a new instance of `collection` with `item` inserted into at the given `in Base.@propagate_inbounds function insert(collection, index, item) @boundscheck checkbounds(collection, index) ret = similar(collection, length(collection) + 1) - @inbounds for i in indices(ret) - if i < index + @inbounds for i in firstindex(ret):(index - 1) ret[i] = collection[i] - elseif i == index - ret[i] = item - else + end + @inbounds ret[index] = item + @inbounds for i in (index + 1):lastindex(ret) ret[i] = collection[i - 1] - end end return ret end