Skip to content

Commit 1e6d771

Browse files
authored
Specialize _memory_offset on number of arguments. (#37444)
1 parent a36c825 commit 1e6d771

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

base/abstractarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,8 @@ function pointer(x::AbstractArray{T}, i::Integer) where T
10701070
end
10711071

10721072
# The distance from pointer(x) to the element at x[I...] in bytes
1073-
_memory_offset(x::DenseArray, I...) = (_to_linear_index(x, I...) - first(LinearIndices(x)))*elsize(x)
1074-
function _memory_offset(x::AbstractArray, I...)
1073+
_memory_offset(x::DenseArray, I::Vararg{Any,N}) where {N} = (_to_linear_index(x, I...) - first(LinearIndices(x)))*elsize(x)
1074+
function _memory_offset(x::AbstractArray, I::Vararg{Any,N}) where {N}
10751075
J = _to_subscript_indices(x, I...)
10761076
return sum(map((i, s, o)->s*(i-o), J, strides(x), Tuple(first(CartesianIndices(x)))))*elsize(x)
10771077
end

0 commit comments

Comments
 (0)