Skip to content

Commit b3526d1

Browse files
committed
Remove bounds-checking logic
1 parent d79f070 commit b3526d1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

base/abstractarray.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,15 +1077,14 @@ function copyto!(deststyle::IndexStyle, dest::AbstractArray, srcstyle::IndexStyl
10771077
end
10781078

10791079
function copyto_unaliased!(::IndexLinear, dest::AbstractArray, ::IndexLinear, src::AbstractArray)
1080-
@_propagate_inbounds_meta
10811080
copyto!(dest, first(LinearIndices(dest)), src, first(LinearIndices(src)), length(src))
10821081
end
10831082
function copyto_unaliased!(deststyle::IndexStyle, dest::AbstractArray, ::IndexStyle, src::AbstractArray)
10841083
isempty(src) && return dest
10851084
destinds, srcinds = LinearIndices(dest), LinearIndices(src)
10861085
idf, isf = first(destinds), first(srcinds)
10871086
Δi = idf - isf
1088-
@boundscheck (checkbounds(Bool, destinds, isf+Δi) & checkbounds(Bool, destinds, last(srcinds)+Δi)) ||
1087+
(checkbounds(Bool, destinds, isf+Δi) & checkbounds(Bool, destinds, last(srcinds)+Δi)) ||
10891088
throw(BoundsError(dest, srcinds))
10901089
if deststyle isa IndexLinear
10911090
# IndexStyle(src) is IndexCartesian, as the linear indexing case is handled separately
@@ -1125,7 +1124,6 @@ end
11251124
# to the parent for contiguous linear views
11261125
function copyto!(dest::AbstractArray, dstart::Integer,
11271126
src::AbstractArray, sstart::Integer, n::Integer)
1128-
@_propagate_inbounds_meta
11291127
# check if the arrays are views that may be unwrapped
11301128
# if yes, try to use the copyto! implementation for the parents
11311129
# if no, then fall back to the default implementation that loops over the arrays
@@ -1136,12 +1134,10 @@ end
11361134
_unwrap_view(A, ind) = A, ind
11371135
# fallback method if neither array is a SubArray, in which case we loop over them
11381136
function __copyto!(dest::A, ::A, dstart, src::B, ::B, sstart, n) where {A,B}
1139-
@_propagate_inbounds_meta
11401137
_copyto!(dest, dstart, src, sstart, n)
11411138
end
11421139
# Forward the copy to the parent if there is any contiguous, linearly indexed view
11431140
function __copyto!(_, destp, dstart, _, srcp, sstart, n)
1144-
@_propagate_inbounds_meta
11451141
copyto!(destp, dstart, srcp, sstart, n)
11461142
end
11471143

@@ -1152,10 +1148,8 @@ function _copyto!(dest::AbstractArray, dstart::Integer,
11521148
n < 0 && throw(ArgumentError(LazyString("tried to copy n=",
11531149
n," elements, but n should be non-negative")))
11541150
destinds, srcinds = LinearIndices(dest), LinearIndices(src)
1155-
@boundscheck begin
1156-
(checkbounds(Bool, destinds, dstart) && checkbounds(Bool, destinds, dstart+n-1)) || throw(BoundsError(dest, dstart:dstart+n-1))
1157-
(checkbounds(Bool, srcinds, sstart) && checkbounds(Bool, srcinds, sstart+n-1)) || throw(BoundsError(src, sstart:sstart+n-1))
1158-
end
1151+
(checkbounds(Bool, destinds, dstart) && checkbounds(Bool, destinds, dstart+n-1)) || throw(BoundsError(dest, dstart:dstart+n-1))
1152+
(checkbounds(Bool, srcinds, sstart) && checkbounds(Bool, srcinds, sstart+n-1)) || throw(BoundsError(src, sstart:sstart+n-1))
11591153
src′ = unalias(dest, src)
11601154
@inbounds for i = 0:n-1
11611155
dest[dstart+i] = src′[sstart+i]

0 commit comments

Comments
 (0)