Skip to content

Commit 2ec00d0

Browse files
committed
Revert "add unsetindex support to more copyto methods (#51760)"
This reverts commit f0a28e9. (cherry picked from commit ff7e7b8)
1 parent 6609f7d commit 2ec00d0

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
@@ -1078,45 +1078,28 @@ function copyto_unaliased!(deststyle::IndexStyle, dest::AbstractArray, srcstyle:
10781078
if srcstyle isa IndexLinear
10791079
# Single-index implementation
10801080
@inbounds for i in srcinds
1081-
if isassigned(src, i)
1082-
dest[i + Δi] = src[i]
1083-
else
1084-
_unsetindex!(dest, i + Δi)
1085-
end
1081+
dest[i + Δi] = src[i]
10861082
end
10871083
else
10881084
# Dual-index implementation
10891085
i = idf - 1
1090-
@inbounds for a in eachindex(src)
1091-
i += 1
1092-
if isassigned(src, a)
1093-
dest[i] = src[a]
1094-
else
1095-
_unsetindex!(dest, i)
1096-
end
1086+
@inbounds for a in src
1087+
dest[i+=1] = a
10971088
end
10981089
end
10991090
else
11001091
iterdest, itersrc = eachindex(dest), eachindex(src)
11011092
if iterdest == itersrc
11021093
# Shared-iterator implementation
1103-
@inbounds for I in iterdest
1104-
if isassigned(src, I)
1105-
dest[I] = src[I]
1106-
else
1107-
_unsetindex!(dest, I)
1108-
end
1094+
for I in iterdest
1095+
@inbounds dest[I] = src[I]
11091096
end
11101097
else
11111098
# Dual-iterator implementation
11121099
ret = iterate(iterdest)
1113-
@inbounds for a in itersrc
1100+
@inbounds for a in src
11141101
idx, state = ret::NTuple{2,Any}
1115-
if isassigned(src, a)
1116-
dest[idx] = src[a]
1117-
else
1118-
_unsetindex!(dest, idx)
1119-
end
1102+
dest[idx] = a
11201103
ret = iterate(iterdest, state)
11211104
end
11221105
end
@@ -1145,11 +1128,7 @@ function copyto!(dest::AbstractArray, dstart::Integer,
11451128
(checkbounds(Bool, srcinds, sstart) && checkbounds(Bool, srcinds, sstart+n-1)) || throw(BoundsError(src, sstart:sstart+n-1))
11461129
src′ = unalias(dest, src)
11471130
@inbounds for i = 0:n-1
1148-
if isassigned(src′, sstart+i)
1149-
dest[dstart+i] = src′[sstart+i]
1150-
else
1151-
_unsetindex!(dest, dstart+i)
1152-
end
1131+
dest[dstart+i] = src′[sstart+i]
11531132
end
11541133
return dest
11551134
end
@@ -1160,7 +1139,7 @@ function copy(a::AbstractArray)
11601139
end
11611140

11621141
function copyto!(B::AbstractVecOrMat{R}, ir_dest::AbstractRange{Int}, jr_dest::AbstractRange{Int},
1163-
A::AbstractVecOrMat{S}, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) where {R,S}
1142+
A::AbstractVecOrMat{S}, ir_src::AbstractRange{Int}, jr_src::AbstractRange{Int}) where {R,S}
11641143
if length(ir_dest) != length(ir_src)
11651144
throw(ArgumentError(LazyString("source and destination must have same size (got ",
11661145
length(ir_src)," and ",length(ir_dest),")")))

0 commit comments

Comments
 (0)