Skip to content

Commit 33573ec

Browse files
authored
Force-specialize on T in cat_similar (#39292)
These methods are tiny (quick to compile), call methods that force-specialize on `T`, and are called by methods that force-specialize on `T`. Consequently, there does not seem to be any good reason to lose inferrability in these methods.
1 parent e9bdb6e commit 33573ec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

base/abstractarray.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ vcat(V::AbstractVector{T}...) where {T} = typed_vcat(T, V...)
14811481
# but that solution currently fails (see #27188 and #27224)
14821482
AbstractVecOrTuple{T} = Union{AbstractVector{<:T}, Tuple{Vararg{T}}}
14831483

1484-
_typed_vcat_similar(V, T, n) = similar(V[1], T, n)
1484+
_typed_vcat_similar(V, ::Type{T}, n) where T = similar(V[1], T, n)
14851485
_typed_vcat(::Type{T}, V::AbstractVecOrTuple{AbstractVector}) where T =
14861486
_typed_vcat!(_typed_vcat_similar(V, T, mapreduce(length, +, V)), V)
14871487

@@ -1577,8 +1577,8 @@ cat_size(A::AbstractArray, d) = size(A, d)
15771577
cat_indices(A, d) = OneTo(1)
15781578
cat_indices(A::AbstractArray, d) = axes(A, d)
15791579

1580-
cat_similar(A, T, shape) = Array{T}(undef, shape)
1581-
cat_similar(A::AbstractArray, T, shape) = similar(A, T, shape)
1580+
cat_similar(A, ::Type{T}, shape) where T = Array{T}(undef, shape)
1581+
cat_similar(A::AbstractArray, ::Type{T}, shape) where T = similar(A, T, shape)
15821582

15831583
cat_shape(dims, shape::Tuple{Vararg{Int}}) = shape
15841584
function cat_shape(dims, shapes::Tuple)

0 commit comments

Comments
 (0)