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 @@ -897,13 +897,23 @@ end
897
897
# # from general iterable to any array
898
898
899
899
function copyto! (dest:: AbstractArray , src)
900
- destiter = eachindex (dest)
901
- y = iterate (destiter)
902
- for x in src
903
- y === nothing &&
900
+ if haslength (src)
901
+ length (dest) < length (src) &&
904
902
throw (ArgumentError (" destination has fewer elements than required" ))
905
- dest[y[1 ]] = x
906
- y = iterate (destiter, y[2 ])
903
+ I = firstindex (dest)
904
+ @inbounds for x in src
905
+ dest[I] = x
906
+ I = nextind (dest, I)
907
+ end
908
+ else
909
+ destiter = eachindex (dest)
910
+ y = iterate (destiter)
911
+ for x in src
912
+ y === nothing &&
913
+ throw (ArgumentError (" destination has fewer elements than required" ))
914
+ dest[y[1 ]] = x
915
+ y = iterate (destiter, y[2 ])
916
+ end
907
917
end
908
918
return dest
909
919
end
You can’t perform that action at this time.
0 commit comments