Skip to content

Commit f64135a

Browse files
committed
remove @boundschecks
1 parent b020ccb commit f64135a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/dimensions.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ function _known_dimnames(::Type{C}, ::Type{P}) where {C,P}
176176
eachop(_inbounds_known_dimname, to_parent_dims(C), known_dimnames(P))
177177
end
178178
@inline function _known_dimname(x::Tuple{Vararg{Any,N}}, dim::CanonicalInt) where {N}
179-
@boundscheck (dim > N || dim < 1) && return :_
179+
# we cannot have `@boundscheck`, else this will depend on bounds checking being enabled
180+
(dim > N || dim < 1) && return :_
180181
return @inbounds(x[dim])
181182
end
182183
@inline _inbounds_known_dimname(x, dim) = @inbounds(_known_dimname(x, dim))
@@ -195,7 +196,9 @@ have a name.
195196
end
196197
_dimnames(::False, x) = ntuple(_->static(:_), Val(ndims(x)))
197198
@inline function _dimname(x::Tuple{Vararg{Any,N}}, dim::CanonicalInt) where {N}
198-
@boundscheck (dim > N || dim < 1) && return static(:_)
199+
# we cannot have `@boundscheck`, else this will depend on bounds checking being enabled
200+
# for calls such as `dimnames(view(x, :, 1, :))`
201+
(dim > N || dim < 1) && return static(:_)
199202
return @inbounds(x[dim])
200203
end
201204
@inline _inbounds_dimname(x, dim) = @inbounds(_dimname(x, dim))

0 commit comments

Comments
 (0)