Skip to content

Commit c72a61a

Browse files
committed
revert copyto!(dest, src)
1 parent 0951b79 commit c72a61a

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

base/abstractarray.jl

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -897,23 +897,13 @@ end
897897
## from general iterable to any array
898898

899899
function copyto!(dest::AbstractArray, src)
900-
if haslength(src)
901-
length(dest) < length(src) &&
900+
destiter = eachindex(dest)
901+
y = iterate(destiter)
902+
for x in src
903+
y === nothing &&
902904
throw(ArgumentError("destination has fewer elements than required"))
903-
i = Int(firstindex(dest))
904-
@inbounds for x in src
905-
dest[i] = x
906-
i += 1
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
905+
dest[y[1]] = x
906+
y = iterate(destiter, y[2])
917907
end
918908
return dest
919909
end

0 commit comments

Comments
 (0)