Skip to content

Commit 148a558

Browse files
committed
Type stability improvement
1 parent f8cb0ff commit 148a558

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

base/abstractarray.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,9 +1692,9 @@ cat_indices(A::AbstractArray, d) = axes(A, d)
16921692
cat_similar(A, ::Type{T}, shape::Tuple) where T = Array{T}(undef, shape)
16931693
cat_similar(A, ::Type{T}, shape::Vector) where T = Array{T}(undef, shape...)
16941694
cat_similar(A::Array, ::Type{T}, shape::Tuple) where T = Array{T}(undef, shape)
1695-
cat_similar(A::Array, ::Type{T}, shape::Vector) where T = Array{T}(undef, shape...)
1695+
cat_similar(A::Array, ::Type{T}, shape::Vector, ::Val{N}) where {T, N} = Array{T, N}(undef, shape...)
16961696
cat_similar(A::AbstractArray, T::Type, shape::Tuple) = similar(A, T, shape)
1697-
cat_similar(A::AbstractArray, T::Type, shape::Vector) = similar(A, T, shape...)
1697+
cat_similar(A::AbstractArray, T::Type, shape::Vector, ::Val{N}) = similar(A, T, shape...)
16981698

16991699
# These are for backwards compatibility (even though internal)
17001700
cat_shape(dims, shape::Tuple{Vararg{Int}}) = shape
@@ -2445,7 +2445,7 @@ function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as
24452445
throw(ArgumentError("mismatched number of elements; expected $(outlen), got $(elementcount)"))
24462446

24472447
# copy into final array
2448-
A = cat_similar(as[1], T, outdims)
2448+
A = cat_similar(as[1], T, outdims, Val(N))
24492449
# @assert all(==(0), currentdims)
24502450
outdims .= 0
24512451
hvncat_fill!(A, currentdims, outdims, d1, d2, as)
@@ -2539,7 +2539,7 @@ function _typed_hvncat_shape(::Type{T}, shape::NTuple{N, Tuple}, row_first, as::
25392539
# @assert all(==(0), blockcounts)
25402540

25412541
# copy into final array
2542-
A = cat_similar(as[1], T, outdims)
2542+
A = cat_similar(as[1], T, outdims, Val(length(outdims)))
25432543
hvncat_fill!(A, currentdims, blockcounts, d1, d2, as)
25442544
return A
25452545
end

0 commit comments

Comments
 (0)