File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -891,13 +891,23 @@ end
891
891
# # from general iterable to any array
892
892
893
893
function copyto! (dest:: AbstractArray , src)
894
- destiter = eachindex (dest)
895
- y = iterate (destiter)
896
- for x in src
897
- y === nothing &&
894
+ if haslength (src)
895
+ length (dest) < length (src) &&
898
896
throw (ArgumentError (" destination has fewer elements than required" ))
899
- dest[y[1 ]] = x
900
- y = iterate (destiter, y[2 ])
897
+ I = firstindex (dest)
898
+ @inbounds for x in src
899
+ dest[I] = x
900
+ I = nextind (dest, I)
901
+ end
902
+ else
903
+ destiter = eachindex (dest)
904
+ y = iterate (destiter)
905
+ for x in src
906
+ y === nothing &&
907
+ throw (ArgumentError (" destination has fewer elements than required" ))
908
+ dest[y[1 ]] = x
909
+ y = iterate (destiter, y[2 ])
910
+ end
901
911
end
902
912
return dest
903
913
end
You can’t perform that action at this time.
0 commit comments