Skip to content

Commit b497f44

Browse files
vtjnashKristofferC
authored andcommitted
simplify call to promote_eltype with repeated elements (#51135)
Helps to short-circuit calls to large splat calls, since those have all the same type elements. Fixes #51011 (cherry picked from commit 3527213)
1 parent 465ff74 commit b497f44

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

base/abstractarray.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1591,10 +1591,14 @@ eltypeof(x::AbstractArray) = eltype(x)
15911591
promote_eltypeof() = error()
15921592
promote_eltypeof(v1) = eltypeof(v1)
15931593
promote_eltypeof(v1, vs...) = promote_type(eltypeof(v1), promote_eltypeof(vs...))
1594+
promote_eltypeof(v1::T, vs::T...) where {T} = eltypeof(v1)
1595+
promote_eltypeof(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T
15941596

15951597
promote_eltype() = error()
15961598
promote_eltype(v1) = eltype(v1)
15971599
promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...))
1600+
promote_eltype(v1::T, vs::T...) where {T} = eltype(T)
1601+
promote_eltype(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T
15981602

15991603
#TODO: ERROR CHECK
16001604
_cat(catdim::Int) = Vector{Any}()

0 commit comments

Comments
 (0)