Skip to content

Commit 8ad4716

Browse files
committed
faster copyto
1 parent fa8be6f commit 8ad4716

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

base/abstractarray.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,18 @@ end
904904

905905
function copyto!(dest::AbstractArray, dstart::Integer, src)
906906
i = Int(dstart)
907-
for x in src
908-
dest[i] = x
909-
i += 1
907+
if haslength(src)
908+
checkbounds(dest, i)
909+
checkbounds(dest, i + length(src) - 1)
910+
for x in src
911+
@inbounds dest[i] = x
912+
i += 1
913+
end
914+
else
915+
for x in src
916+
dest[i] = x
917+
i += 1
918+
end
910919
end
911920
return dest
912921
end

0 commit comments

Comments
 (0)