Skip to content

Commit 274b9b1

Browse files
committed
Revert "Replace @pures"
This reverts commit 036a28c.
1 parent 66ec63f commit 274b9b1

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/static.jl

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Base.promote_rule(::Type{<:StaticBool}, ::Type{<:StaticBool}) = StaticBool
250250
Base.promote_rule(::Type{<:StaticBool}, ::Type{Bool}) = Bool
251251
Base.promote_rule(::Type{Bool}, ::Type{<:StaticBool}) = Bool
252252

253-
@generated _get_tuple(::Type{T}, ::StaticInt{i}) where {T<:Tuple, i} = T.parameters[i]
253+
Base.@pure _get_tuple(::Type{T}, ::StaticInt{i}) where {T<:Tuple, i} = T.parameters[i]
254254

255255
Base.all(::Tuple{Vararg{True}}) = true
256256
Base.all(::Tuple{Vararg{Union{True,False}}}) = false
@@ -260,26 +260,19 @@ Base.any(::Tuple{Vararg{True}}) = true
260260
Base.any(::Tuple{Vararg{Union{True,False}}}) = true
261261
Base.any(::Tuple{Vararg{False}}) = false
262262

263-
@inline nstatic(::Val{N}) where {N} = ntuple(i -> StaticInt(i), Val(N))
263+
Base.@pure nstatic(::Val{N}) where {N} = ntuple(i -> StaticInt(i), Val(N))
264264

265-
invariant_permutation(::Any, ::Any) = False()
266-
function invariant_permutation(x::T, y::T) where {N,T<:Tuple{Vararg{StaticInt,N}}}
267-
if x === nstatic(Val(N))
268-
return True()
269-
else
270-
return False()
271-
end
272-
end
265+
@pure is_permuting(perm::Tuple{Vararg{StaticInt,N}}) where {N} = perm !== nstatic(Val(N))
273266

274-
permute(x::Tuple, perm::Val) = permute(x, static(perm))
275-
# TODO delete this? permute(x::Tuple, perm::Tuple) = eachop(getindex, x, perm)
276-
function permute(x::Tuple{Vararg{Any,N}}, perm::Tuple{Vararg{StaticInt,N}}) where {N}
277-
if invariant_permutation(perm, perm) <: False
267+
permute(x::Tuple, perm::Tuple) = eachop(getindex, x, perm)
268+
function permute(x::Tuple{Vararg{Any,N}}, perm::Tuple{Vararg{Any,N}}) where {N}
269+
if is_permuting(perm)
278270
return eachop(getindex, x, perm)
279271
else
280272
return x
281273
end
282274
end
275+
permute(x::Tuple, perm::Val) = permute(x, static(perm))
283276

284277
@generated function eachop(op, x, y, ::I) where {I}
285278
t = Expr(:tuple)

0 commit comments

Comments
 (0)