@@ -99,7 +99,7 @@ function vect(X...)
99
99
T = promote_typeof (X... )
100
100
# T[ X[i] for i=1:length(X) ]
101
101
# TODO : this is currently much faster. should figure out why. not clear.
102
- return copy ! (Vector {T} (uninitialized, length (X)), X)
102
+ return copyto ! (Vector {T} (uninitialized, length (X)), X)
103
103
end
104
104
105
105
size (a:: Array , d) = arraysize (a, d)
143
143
# # copy ##
144
144
145
145
"""
146
- unsafe_copy !(dest::Ptr{T}, src::Ptr{T}, N)
146
+ unsafe_copyto !(dest::Ptr{T}, src::Ptr{T}, N)
147
147
148
148
Copy `N` elements from a source pointer to a destination, with no checking. The size of an
149
149
element is determined by the type of the pointers.
@@ -152,7 +152,7 @@ The `unsafe` prefix on this function indicates that no validation is performed o
152
152
pointers `dest` and `src` to ensure that they are valid. Incorrect usage may corrupt or
153
153
segfault your program, in the same manner as C.
154
154
"""
155
- function unsafe_copy ! (dest:: Ptr{T} , src:: Ptr{T} , n) where T
155
+ function unsafe_copyto ! (dest:: Ptr{T} , src:: Ptr{T} , n) where T
156
156
# Do not use this to copy data between pointer arrays.
157
157
# It can't be made safe no matter how carefully you checked.
158
158
ccall (:memmove , Ptr{Void}, (Ptr{Void}, Ptr{Void}, UInt),
@@ -161,7 +161,7 @@ function unsafe_copy!(dest::Ptr{T}, src::Ptr{T}, n) where T
161
161
end
162
162
163
163
"""
164
- unsafe_copy !(dest::Array, do, src::Array, so, N)
164
+ unsafe_copyto !(dest::Array, do, src::Array, so, N)
165
165
166
166
Copy `N` elements from a source array to a destination, starting at offset `so` in the
167
167
source and `do` in the destination (1-indexed).
@@ -170,11 +170,11 @@ The `unsafe` prefix on this function indicates that no validation is performed t
170
170
that N is inbounds on either array. Incorrect usage may corrupt or segfault your program, in
171
171
the same manner as C.
172
172
"""
173
- function unsafe_copy ! (dest:: Array{T} , doffs, src:: Array{T} , soffs, n) where T
173
+ function unsafe_copyto ! (dest:: Array{T} , doffs, src:: Array{T} , soffs, n) where T
174
174
t1 = @_gc_preserve_begin dest
175
175
t2 = @_gc_preserve_begin src
176
176
if isbits (T)
177
- unsafe_copy ! (pointer (dest, doffs), pointer (src, soffs), n)
177
+ unsafe_copyto ! (pointer (dest, doffs), pointer (src, soffs), n)
178
178
elseif isbitsunion (T)
179
179
ccall (:memmove , Ptr{Void}, (Ptr{Void}, Ptr{Void}, UInt),
180
180
pointer (dest, doffs), pointer (src, soffs), n * Base. bitsunionsize (T))
@@ -193,21 +193,21 @@ function unsafe_copy!(dest::Array{T}, doffs, src::Array{T}, soffs, n) where T
193
193
end
194
194
195
195
"""
196
- copy !(dest, do, src, so, N)
196
+ copyto !(dest, do, src, so, N)
197
197
198
198
Copy `N` elements from collection `src` starting at offset `so`, to array `dest` starting at
199
199
offset `do`. Return `dest`.
200
200
"""
201
- function copy ! (dest:: Array{T} , doffs:: Integer , src:: Array{T} , soffs:: Integer , n:: Integer ) where T
201
+ function copyto ! (dest:: Array{T} , doffs:: Integer , src:: Array{T} , soffs:: Integer , n:: Integer ) where T
202
202
n == 0 && return dest
203
203
n > 0 || throw (ArgumentError (string (" tried to copy n=" , n, " elements, but n should be nonnegative" )))
204
204
if soffs < 1 || doffs < 1 || soffs+ n- 1 > length (src) || doffs+ n- 1 > length (dest)
205
205
throw (BoundsError ())
206
206
end
207
- unsafe_copy ! (dest, doffs, src, soffs, n)
207
+ unsafe_copyto ! (dest, doffs, src, soffs, n)
208
208
end
209
209
210
- copy ! (dest:: Array{T} , src:: Array{T} ) where {T} = copy ! (dest, 1 , src, 1 , length (src))
210
+ copyto ! (dest:: Array{T} , src:: Array{T} ) where {T} = copyto ! (dest, 1 , src, 1 , length (src))
211
211
212
212
"""
213
213
copy(x)
@@ -403,7 +403,7 @@ convert(::Type{Array{T}}, x::Array{T,n}) where {T,n} = x
403
403
convert (:: Type{Array{T,n}} , x:: Array{T,n} ) where {T,n} = x
404
404
405
405
convert (:: Type{Array{T}} , x:: AbstractArray{S,n} ) where {T,n,S} = convert (Array{T,n}, x)
406
- convert (:: Type{Array{T,n}} , x:: AbstractArray{S,n} ) where {T,n,S} = copy ! (Array {T,n} (uninitialized, size (x)), x)
406
+ convert (:: Type{Array{T,n}} , x:: AbstractArray{S,n} ) where {T,n,S} = copyto ! (Array {T,n} (uninitialized, size (x)), x)
407
407
408
408
promote_rule (a:: Type{Array{T,n}} , b:: Type{Array{S,n}} ) where {T,n,S} = el_same (promote_type (T,S), a, b)
409
409
@@ -432,8 +432,8 @@ julia> collect(Float64, 1:2:5)
432
432
"""
433
433
collect (:: Type{T} , itr) where {T} = _collect (T, itr, iteratorsize (itr))
434
434
435
- _collect (:: Type{T} , itr, isz:: HasLength ) where {T} = copy ! (Vector {T} (uninitialized, Int (length (itr):: Integer )), itr)
436
- _collect (:: Type{T} , itr, isz:: HasShape ) where {T} = copy ! (similar (Array{T}, axes (itr)), itr)
435
+ _collect (:: Type{T} , itr, isz:: HasLength ) where {T} = copyto ! (Vector {T} (uninitialized, Int (length (itr):: Integer )), itr)
436
+ _collect (:: Type{T} , itr, isz:: HasShape ) where {T} = copyto ! (similar (Array{T}, axes (itr)), itr)
437
437
function _collect (:: Type{T} , itr, isz:: SizeUnknown ) where T
438
438
a = Vector {T} ()
439
439
for x in itr
@@ -475,7 +475,7 @@ collect(A::AbstractArray) = _collect_indices(axes(A), A)
475
475
collect_similar (cont, itr) = _collect (cont, itr, iteratoreltype (itr), iteratorsize (itr))
476
476
477
477
_collect (cont, itr, :: HasEltype , isz:: Union{HasLength,HasShape} ) =
478
- copy ! (_similar_for (cont, eltype (itr), itr, isz), itr)
478
+ copyto ! (_similar_for (cont, eltype (itr), itr, isz), itr)
479
479
480
480
function _collect (cont, itr, :: HasEltype , isz:: SizeUnknown )
481
481
a = _similar_for (cont, eltype (itr), itr, isz)
@@ -485,12 +485,12 @@ function _collect(cont, itr, ::HasEltype, isz::SizeUnknown)
485
485
return a
486
486
end
487
487
488
- _collect_indices (:: Tuple{} , A) = copy ! (Array {eltype(A),0} (uninitialized), A)
488
+ _collect_indices (:: Tuple{} , A) = copyto ! (Array {eltype(A),0} (uninitialized), A)
489
489
_collect_indices (indsA:: Tuple{Vararg{OneTo}} , A) =
490
- copy ! (Array {eltype(A)} (uninitialized, length .(indsA)), A)
490
+ copyto ! (Array {eltype(A)} (uninitialized, length .(indsA)), A)
491
491
function _collect_indices (indsA, A)
492
492
B = Array {eltype(A)} (uninitialized, length .(indsA))
493
- copy ! (B, CartesianIndices (axes (B)), A, CartesianIndices (indsA))
493
+ copyto ! (B, CartesianIndices (axes (B)), A, CartesianIndices (indsA))
494
494
end
495
495
496
496
# define this as a macro so that the call to Inference
@@ -563,7 +563,7 @@ function collect_to!(dest::AbstractArray{T}, itr, offs, st) where T
563
563
else
564
564
R = typejoin (T, S)
565
565
new = similar (dest, R)
566
- copy ! (new,1 , dest,1 , i- 1 )
566
+ copyto ! (new,1 , dest,1 , i- 1 )
567
567
@inbounds new[i] = el
568
568
return collect_to! (new, itr, i+ 1 , st)
569
569
end
@@ -589,7 +589,7 @@ function grow_to!(dest, itr, st)
589
589
# TODO : merge back these two branches when copy! is re-enabled for sets
590
590
union! (new, dest)
591
591
else
592
- copy ! (new, dest)
592
+ copyto ! (new, dest)
593
593
end
594
594
push! (new, el)
595
595
return grow_to! (new, itr, st)
@@ -628,22 +628,22 @@ function getindex end
628
628
@eval getindex (A:: Array , i1:: Int ) = arrayref ($ (Expr (:boundscheck )), A, i1)
629
629
@eval getindex (A:: Array , i1:: Int , i2:: Int , I:: Int... ) = (@_inline_meta ; arrayref ($ (Expr (:boundscheck )), A, i1, i2, I... ))
630
630
631
- # Faster contiguous indexing using copy ! for UnitRange and Colon
631
+ # Faster contiguous indexing using copyto ! for UnitRange and Colon
632
632
function getindex (A:: Array , I:: UnitRange{Int} )
633
633
@_inline_meta
634
634
@boundscheck checkbounds (A, I)
635
635
lI = length (I)
636
636
X = similar (A, lI)
637
637
if lI > 0
638
- unsafe_copy ! (X, 1 , A, first (I), lI)
638
+ unsafe_copyto ! (X, 1 , A, first (I), lI)
639
639
end
640
640
return X
641
641
end
642
642
function getindex (A:: Array , c:: Colon )
643
643
lI = length (A)
644
644
X = similar (A, lI)
645
645
if lI > 0
646
- unsafe_copy ! (X, 1 , A, 1 , lI)
646
+ unsafe_copyto ! (X, 1 , A, 1 , lI)
647
647
end
648
648
return X
649
649
end
@@ -694,14 +694,14 @@ function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int})
694
694
return A
695
695
end
696
696
697
- # Faster contiguous setindex! with copy !
697
+ # Faster contiguous setindex! with copyto !
698
698
function setindex! (A:: Array{T} , X:: Array{T} , I:: UnitRange{Int} ) where T
699
699
@_inline_meta
700
700
@boundscheck checkbounds (A, I)
701
701
lI = length (I)
702
702
@boundscheck setindex_shape_check (X, lI)
703
703
if lI > 0
704
- unsafe_copy ! (A, first (I), X, 1 , lI)
704
+ unsafe_copyto ! (A, first (I), X, 1 , lI)
705
705
end
706
706
return A
707
707
end
@@ -710,7 +710,7 @@ function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T
710
710
lI = length (A)
711
711
@boundscheck setindex_shape_check (X, lI)
712
712
if lI > 0
713
- unsafe_copy ! (A, 1 , X, 1 , lI)
713
+ unsafe_copyto ! (A, 1 , X, 1 , lI)
714
714
end
715
715
return A
716
716
end
@@ -806,7 +806,7 @@ function append!(a::Array{<:Any,1}, items::AbstractVector)
806
806
itemindices = eachindex (items)
807
807
n = length (itemindices)
808
808
_growend! (a, n)
809
- copy ! (a, length (a)- n+ 1 , items, first (itemindices), n)
809
+ copyto ! (a, length (a)- n+ 1 , items, first (itemindices), n)
810
810
return a
811
811
end
812
812
@@ -850,9 +850,9 @@ function prepend!(a::Array{<:Any,1}, items::AbstractVector)
850
850
n = length (itemindices)
851
851
_growbeg! (a, n)
852
852
if a === items
853
- copy ! (a, 1 , items, n+ 1 , n)
853
+ copyto ! (a, 1 , items, n+ 1 , n)
854
854
else
855
- copy ! (a, 1 , items, first (itemindices), n)
855
+ copyto ! (a, 1 , items, first (itemindices), n)
856
856
end
857
857
return a
858
858
end
@@ -1720,7 +1720,7 @@ function find(testf::Function, A)
1720
1720
end
1721
1721
end
1722
1722
I = Vector {Int} (uninitialized, length (tmpI))
1723
- copy ! (I, tmpI)
1723
+ copyto ! (I, tmpI)
1724
1724
return I
1725
1725
end
1726
1726
_index_remapper (A:: AbstractArray ) = linearindices (A)
0 commit comments