Skip to content

Commit 4a47e47

Browse files
committed
Code style change.
1 parent 4f431c9 commit 4a47e47

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/structarray.jl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,12 @@ function StructArrayStyle{S, M}(::Val{N}) where {S, M, N}
453453
return StructArrayStyle{T, N}()
454454
end
455455

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-
461456
# StructArrayStyle is a wrapped style.
462457
# Here we try our best to resolve style conflict.
463458
function BroadcastStyle(b::AbstractArrayStyle{M}, a::StructArrayStyle{S, N}) where {S, N, M}
459+
N′ = M === Any || N === Any ? Any : max(M, N)
464460
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′}()
469462
end
470463
BroadcastStyle(::StructArrayStyle, ::DefaultArrayStyle) = Unknown()
471464

@@ -482,8 +475,7 @@ BroadcastStyle(::Type{SA}) where {SA<:StructArray} = StructArrayStyle{typeof(cst
482475
# Here we use `similar` defined for `S` to build the dest Array.
483476
function Base.similar(bc::Broadcasted{StructArrayStyle{S, N}}, ::Type{ElType}) where {S, N, ElType}
484477
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)
487479
end
488480

489481
# Unwrapper to recover the behaviour defined by parent style.

0 commit comments

Comments
 (0)