Skip to content

Commit 78210bf

Browse files
committed
reduce the inline cost of checkindex hack.
The correctness holds based on the assumption that `last(ind) > 0`, which should be true if `OneTo` was created via the inner constructor.
1 parent d54ba50 commit 78210bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

base/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ false
767767
checkindex(::Type{Bool}, inds::AbstractUnitRange, i) =
768768
throw(ArgumentError("unable to check bounds for indices of type $(typeof(i))"))
769769
checkindex(::Type{Bool}, inds::AbstractUnitRange, i::Real) = (first(inds) <= i) & (i <= last(inds))
770-
checkindex(::Type{Bool}, ind::OneTo{T}, i::T) where {T<:BitInteger} = unsigned(i-1) < last(ind)
770+
checkindex(::Type{Bool}, ind::OneTo{T}, i::T) where {T<:BitInteger} = unsigned(i - one(i)) < unsigned(last(ind))
771771
checkindex(::Type{Bool}, inds::AbstractUnitRange, ::Colon) = true
772772
checkindex(::Type{Bool}, inds::AbstractUnitRange, ::Slice) = true
773773
function checkindex(::Type{Bool}, inds::AbstractUnitRange, r::AbstractRange)

0 commit comments

Comments
 (0)