Skip to content

Commit 6a4dff1

Browse files
authored
Remove @generated from map_tuple_type and flatten_tuples (#337)
This eliminates all `@generated` calls from ArrayInterfaceCore. This is mostly accomplished by making `ntuple` carry the bulk of the work when generating a new tuple. Special thanks to @N5N3 for help with `flatten_tuples`
1 parent 7819a3c commit 6a4dff1

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

lib/ArrayInterfaceCore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterfaceCore"
22
uuid = "30b0a656-2188-435a-8636-2ec0e6a096e2"
3-
version = "0.1.15"
3+
version = "0.1.16"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

lib/ArrayInterfaceCore/src/ArrayInterfaceCore.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,8 @@ julia> ArrayInterfaceCore.map_tuple_type(sqrt, Tuple{1,4,16})
3535
3636
```
3737
"""
38-
function map_tuple_type(f::F, ::Type{T}) where {F,T<:Tuple}
39-
if @generated
40-
t = Expr(:tuple)
41-
for i in 1:fieldcount(T)
42-
push!(t.args, :(f($(fieldtype(T, i)))))
43-
end
44-
Expr(:block, Expr(:meta, :inline), t)
45-
else
46-
Tuple(f(fieldtype(T, i)) for i in 1:fieldcount(T))
47-
end
38+
@inline function map_tuple_type(f, @nospecialize(T::Type))
39+
ntuple(i -> f(fieldtype(T, i)), Val{fieldcount(T)}())
4840
end
4941

5042
"""

0 commit comments

Comments
 (0)