Skip to content

Commit ff7e7b8

Browse files
KristofferCKristofferC
authored andcommitted
Revert "add unsetindex support to more copyto methods (#51760)"
This reverts commit f0a28e9.
1 parent 20c3628 commit ff7e7b8

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

base/abstractarray.jl

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,45 +1083,28 @@ function copyto_unaliased!(deststyle::IndexStyle, dest::AbstractArray, srcstyle:
10831083
if srcstyle isa IndexLinear
10841084
# Single-index implementation
10851085
@inbounds for i in srcinds
1086-
if isassigned(src, i)
1087-
dest[i + Δi] = src[i]
1088-
else
1089-
_unsetindex!(dest, i + Δi)
1090-
end
1086+
dest[i + Δi] = src[i]
10911087
end
10921088
else
10931089
# Dual-index implementation
10941090
i = idf - 1
1095-
@inbounds for a in eachindex(src)
1096-
i += 1
1097-
if isassigned(src, a)
1098-
dest[i] = src[a]
1099-
else
1100-
_unsetindex!(dest, i)
1101-
end
1091+
@inbounds for a in src
1092+
dest[i+=1] = a
11021093
end
11031094
end
11041095
else
11051096
iterdest, itersrc = eachindex(dest), eachindex(src)
11061097
if iterdest == itersrc
11071098
# Shared-iterator implementation
1108-
@inbounds for I in iterdest
1109-
if isassigned(src, I)
1110-
dest[I] = src[I]
1111-
else
1112-
_unsetindex!(dest, I)
1113-
end
1099+
for I in iterdest
1100+
@inbounds dest[I] = src[I]
11141101
end
11151102
else
11161103
# Dual-iterator implementation
11171104
ret = iterate(iterdest)
1118-
@inbounds for a in itersrc
1105+
@inbounds for a in src
11191106
idx, state = ret::NTuple{2,Any}
1120-
if isassigned(src, a)
1121-
dest[idx] = src[a]
1122-
else
1123-
_unsetindex!(dest, idx)
1124-
end
1107+
dest[idx] = a
11251108
ret = iterate(iterdest, state)
11261109
end
11271110
end
@@ -1150,11 +1133,7 @@ function copyto!(dest::AbstractArray, dstart::Integer,
11501133
(checkbounds(Bool, srcinds, sstart) && checkbounds(Bool, srcinds, sstart+n-1)) || throw(BoundsError(src, sstart:sstart+n-1))
11511134
src′ = unalias(dest, src)
11521135
@inbounds for i = 0:n-1
1153-
if isassigned(src′, sstart+i)
1154-
dest[dstart+i] = src′[sstart+i]
1155-
else
1156-
_unsetindex!(dest, dstart+i)
1157-
end
1136+
dest[dstart+i] = src′[sstart+i]
11581137
end
11591138
return dest
11601139
end
@@ -1165,7 +1144,7 @@ function copy(a::AbstractArray)
11651144
end
11661145

11671146
function copyto!(B::AbstractVecOrMat{R}, ir_dest::AbstractRange{Int}, jr_dest::AbstractRange{Int},
1168-
A::AbstractVecOrMat{S}, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) where {R,S}
1147+
A::AbstractVecOrMat{S}, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) where {R,S}
11691148
if length(ir_dest) != length(ir_src)
11701149
throw(ArgumentError(LazyString("source and destination must have same size (got ",
11711150
length(ir_src)," and ",length(ir_dest),")")))

0 commit comments

Comments
 (0)