Skip to content

Commit

Permalink
revert copyto!(dest, src)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Jan 13, 2022
1 parent 43bb1f5 commit d583640
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -891,23 +891,13 @@ end
## from general iterable to any array

function copyto!(dest::AbstractArray, src)
if haslength(src)
length(dest) < length(src) &&
destiter = eachindex(dest)
y = iterate(destiter)
for x in src
y === nothing &&
throw(ArgumentError("destination has fewer elements than required"))
i = Int(firstindex(dest))
@inbounds for x in src
dest[i] = x
i += 1
end
else
destiter = eachindex(dest)
y = iterate(destiter)
for x in src
y === nothing &&
throw(ArgumentError("destination has fewer elements than required"))
dest[y[1]] = x
y = iterate(destiter, y[2])
end
dest[y[1]] = x
y = iterate(destiter, y[2])
end
return dest
end
Expand Down

0 comments on commit d583640

Please sign in to comment.