From b497f44d8d7b98932f9fde1627686fef9a096675 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 1 Sep 2023 14:50:26 -0400 Subject: [PATCH] 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 3527213ccb1bfe0c48feab5da64d30cadbd4c526) --- base/abstractarray.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index c9a544425d8d0..8b8e4a760eb9b 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -1591,10 +1591,14 @@ eltypeof(x::AbstractArray) = eltype(x) promote_eltypeof() = error() promote_eltypeof(v1) = eltypeof(v1) promote_eltypeof(v1, vs...) = promote_type(eltypeof(v1), promote_eltypeof(vs...)) +promote_eltypeof(v1::T, vs::T...) where {T} = eltypeof(v1) +promote_eltypeof(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T promote_eltype() = error() promote_eltype(v1) = eltype(v1) promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...)) +promote_eltype(v1::T, vs::T...) where {T} = eltype(T) +promote_eltype(v1::AbstractArray{T}, vs::AbstractArray{T}...) where {T} = T #TODO: ERROR CHECK _cat(catdim::Int) = Vector{Any}()