Skip to content

Commit 0b6ed6f

Browse files
simplify
1 parent a639ef9 commit 0b6ed6f

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

ext/ArrayInterfaceStaticExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import ArrayInterface: known_first, known_step, known_last
3030
import ArrayInterface: offsets, axes_types, offset1, indices, known_offsets, stride_rank, strides, dense_dims, contiguous_axis, known_length, contiguous_batch_size,
3131
contiguous_axis_indicator, is_column_major, _all_dense, AbstractArray2, dimnames, known_dimnames, known_offset1, known_strides, LazyAxis, lazy_axes, BroadcastAxis, broadcast_axis,
3232
to_axes, find_all_dimnames, to_dims, known_size, deleteat, insert, static_size, is_lazy_conjugate, static_stride, static_strides, has_dimnames, unsafe_reconstruct, static_to_indices,
33-
to_index, unsafe_setindex!, unsafe_getindex, static_axes, to_axis, is_dense, static_getindex, _strides2int
33+
to_index, unsafe_setindex!, unsafe_getindex, static_axes, to_axis, is_dense, static_getindex
3434

3535
if isdefined(Base, :get_extension)
3636
using Static

ext/static/array_index.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ end
1212
return _strides2int(offsets(x), static_strides(x), Tuple(i)) + static(1)
1313
end
1414

15-
15+
@generated function _strides2int(o::O, s::S, i::I) where {O,S,I}
16+
N = known_length(S)
17+
out = :()
18+
for i in 1:N
19+
tmp = :(((getfield(i, $i) - getfield(o, $i)) * getfield(s, $i)))
20+
out = ifelse(i === 1, tmp, :($out + $tmp))
21+
end
22+
return Expr(:block, Expr(:meta, :inline), out)
23+
end

src/ArrayInterface.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,16 +1144,6 @@ function to_axis end
11441144
function is_dense end
11451145
function static_getindex end
11461146

1147-
@generated function _strides2int(o::O, s::S, i::I) where {O,S,I}
1148-
N = known_length(S)
1149-
out = :()
1150-
for i in 1:N
1151-
tmp = :(((getfield(i, $i) - getfield(o, $i)) * getfield(s, $i)))
1152-
out = ifelse(i === 1, tmp, :($out + $tmp))
1153-
end
1154-
return Expr(:block, Expr(:meta, :inline), out)
1155-
end
1156-
11571147
## Shadowing
11581148
## This is really dumb, it breaks every style guide idea, who did this, this is so bad, remove ASAP
11591149

0 commit comments

Comments
 (0)