We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 66a9e6a commit d973c64Copy full SHA for d973c64
src/ArrayInterface.jl
@@ -551,14 +551,12 @@ Return a new instance of `collection` with `item` inserted into at the given `in
551
Base.@propagate_inbounds function insert(collection, index, item)
552
@boundscheck checkbounds(collection, index)
553
ret = similar(collection, length(collection) + 1)
554
- @inbounds for i in indices(ret)
555
- if i < index
+ @inbounds for i in firstindex(ret):(index - 1)
556
ret[i] = collection[i]
557
- elseif i == index
558
- ret[i] = item
559
- else
+ end
+ @inbounds ret[index] = item
+ @inbounds for i in (index + 1):lastindex(ret)
560
ret[i] = collection[i - 1]
561
- end
562
end
563
return ret
564
0 commit comments