@@ -453,19 +453,12 @@ function StructArrayStyle{S, M}(::Val{N}) where {S, M, N}
453
453
return StructArrayStyle {T, N} ()
454
454
end
455
455
456
- _dimmax (a:: Integer , b:: Integer ) = max (a, b)
457
- _dimmax (:: Type{Any} , :: Integer ) = Any
458
- _dimmax (:: Integer ,:: Type{Any} ) = Any
459
- _dimmax (:: Type{Any} ,:: Type{Any} ) = Any
460
-
461
456
# StructArrayStyle is a wrapped style.
462
457
# Here we try our best to resolve style conflict.
463
458
function BroadcastStyle (b:: AbstractArrayStyle{M} , a:: StructArrayStyle{S, N} ) where {S, N, M}
459
+ N′ = M === Any || N === Any ? Any : max (M, N)
464
460
S′ = Broadcast. result_style (S (), b)
465
- if S′ isa StructArrayStyle # avoid double wrap
466
- return typeof (S′)(Val {_dimmax(N, M)} ())
467
- end
468
- StructArrayStyle {typeof(S′), _dimmax(N, M)} ()
461
+ return S′ isa StructArrayStyle ? typeof (S′)(Val {N′} ()) : StructArrayStyle {typeof(S′), N′} ()
469
462
end
470
463
BroadcastStyle (:: StructArrayStyle , :: DefaultArrayStyle ) = Unknown ()
471
464
@@ -482,8 +475,7 @@ BroadcastStyle(::Type{SA}) where {SA<:StructArray} = StructArrayStyle{typeof(cst
482
475
# Here we use `similar` defined for `S` to build the dest Array.
483
476
function Base. similar (bc:: Broadcasted{StructArrayStyle{S, N}} , :: Type{ElType} ) where {S, N, ElType}
484
477
bc′ = convert (Broadcasted{S}, bc)
485
- isnonemptystructtype (ElType) || return similar (bc′, ElType)
486
- return buildfromschema (T -> similar (bc′, T), ElType)
478
+ return isnonemptystructtype (ElType) ? similar (bc′, ElType) : buildfromschema (T -> similar (bc′, T), ElType)
487
479
end
488
480
489
481
# Unwrapper to recover the behaviour defined by parent style.
0 commit comments