@@ -250,7 +250,7 @@ Base.promote_rule(::Type{<:StaticBool}, ::Type{<:StaticBool}) = StaticBool
250
250
Base. promote_rule (:: Type{<:StaticBool} , :: Type{Bool} ) = Bool
251
251
Base. promote_rule (:: Type{Bool} , :: Type{<:StaticBool} ) = Bool
252
252
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]
254
254
255
255
Base. all (:: Tuple{Vararg{True}} ) = true
256
256
Base. all (:: Tuple{Vararg{Union{True,False}}} ) = false
@@ -260,26 +260,19 @@ Base.any(::Tuple{Vararg{True}}) = true
260
260
Base. any (:: Tuple{Vararg{Union{True,False}}} ) = true
261
261
Base. any (:: Tuple{Vararg{False}} ) = false
262
262
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))
264
264
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))
273
266
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)
278
270
return eachop (getindex, x, perm)
279
271
else
280
272
return x
281
273
end
282
274
end
275
+ permute (x:: Tuple , perm:: Val ) = permute (x, static (perm))
283
276
284
277
@generated function eachop (op, x, y, :: I ) where {I}
285
278
t = Expr (:tuple )
0 commit comments