Skip to content

Commit 7131982

Browse files
committed
revert copyto!(dest, src)
1 parent 58ad472 commit 7131982

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
@@ -901,23 +901,13 @@ end
901901
typeof(function copyto! end).name.max_methods = UInt8(1)
902902

903903
function copyto!(dest::AbstractArray, src)
904-
if haslength(src)
905-
length(dest) < length(src) &&
904+
destiter = eachindex(dest)
905+
y = iterate(destiter)
906+
for x in src
907+
y === nothing &&
906908
throw(ArgumentError("destination has fewer elements than required"))
907-
i = Int(firstindex(dest))
908-
@inbounds for x in src
909-
dest[i] = x
910-
i += 1
911-
end
912-
else
913-
destiter = eachindex(dest)
914-
y = iterate(destiter)
915-
for x in src
916-
y === nothing &&
917-
throw(ArgumentError("destination has fewer elements than required"))
918-
dest[y[1]] = x
919-
y = iterate(destiter, y[2])
920-
end
909+
dest[y[1]] = x
910+
y = iterate(destiter, y[2])
921911
end
922912
return dest
923913
end

0 commit comments

Comments
 (0)