Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,8 @@ typed_hcat(::Type{T}) where {T} = Vector{T}()
## cat: special cases
vcat(X::T...) where {T} = T[ X[i] for i=eachindex(X) ]
vcat(X::T...) where {T<:Number} = T[ X[i] for i=eachindex(X) ]
hcat(X::T...) where {T} = T[ X[j] for i=1:1, j=eachindex(X) ]
hcat(X::T...) where {T<:Number} = T[ X[j] for i=1:1, j=eachindex(X) ]
hcat(X::T...) where {T} = T[ X[j] for _=1:1, j=eachindex(X) ]
hcat(X::T...) where {T<:Number} = T[ X[j] for _=1:1, j=eachindex(X) ]

vcat(X::Number...) = hvcat_fill!(Vector{promote_typeof(X...)}(undef, length(X)), X)
hcat(X::Number...) = hvcat_fill!(Matrix{promote_typeof(X...)}(undef, 1,length(X)), X)
Expand Down Expand Up @@ -1827,7 +1827,7 @@ function cat_shape(dims, shapes::Tuple)
return out_shape
end
# The new way to compute the shape (more inferable than combining cat_size & cat_shape, due to Varargs + issue#36454)
cat_size_shape(dims) = ntuple(zero, Val(length(dims)))
cat_size_shape(dims) = ntuple(Returns(0), Val(length(dims)))
@inline cat_size_shape(dims, X, tail...) = _cat_size_shape(dims, _cshp(1, dims, (), cat_size(X)), tail...)
_cat_size_shape(dims, shape) = shape
@inline _cat_size_shape(dims, shape, X, tail...) = _cat_size_shape(dims, _cshp(1, dims, shape, cat_size(X)), tail...)
Expand Down Expand Up @@ -1881,7 +1881,7 @@ end
@inline cat_t(::Type{T}, X...; dims) where {T} = _cat_t(dims, T, X...)

# Why isn't this called `__cat!`?
__cat(A, shape, catdims, X...) = __cat_offset!(A, shape, catdims, ntuple(zero, length(shape)), X...)
__cat(A, shape, catdims, X...) = __cat_offset!(A, shape, catdims, ntuple(Returns(0), length(shape)), X...)

function __cat_offset!(A, shape, catdims, offsets, x, X...)
# splitting the "work" on x from X... may reduce latency (fewer costly specializations)
Expand Down Expand Up @@ -2388,13 +2388,13 @@ _typed_hvncat_0d_only_one() =
function _typed_hvncat(::Type{T}, ::Val{N}) where {T, N}
N < 0 &&
throw(ArgumentError("concatenation dimension must be non-negative"))
return Array{T, N}(undef, ntuple(x -> 0, Val(N)))
return Array{T, N}(undef, ntuple(Returns(0), Val(N)))
end

function _typed_hvncat(T::Type, ::Val{N}, xs::Number...) where N
N < 0 &&
throw(ArgumentError("concatenation dimension must be non-negative"))
A = cat_similar(xs[1], T, (ntuple(x -> 1, Val(N - 1))..., length(xs)))
A = cat_similar(xs[1], T, (ntuple(Returns(1), Val(N - 1))..., length(xs)))
hvncat_fill!(A, false, xs)
return A
end
Expand All @@ -2408,7 +2408,7 @@ function _typed_hvncat(::Type{T}, ::Val{N}, as::AbstractArray...) where {T, N}
throw(ArgumentError("concatenation dimension must be non-negative"))
for a ∈ as
ndims(a) <= N || all(x -> size(a, x) == 1, (N + 1):ndims(a)) ||
return _typed_hvncat(T, (ntuple(x -> 1, Val(N - 1))..., length(as), 1), false, as...)
return _typed_hvncat(T, (ntuple(Returns(1), Val(N - 1))..., length(as), 1), false, as...)
# the extra 1 is to avoid an infinite cycle
end

Expand All @@ -2423,7 +2423,7 @@ function _typed_hvncat(::Type{T}, ::Val{N}, as::AbstractArray...) where {T, N}
end
end

A = cat_similar(as[1], T, (ntuple(d -> size(as[1], d), N - 1)..., Ndim, ntuple(x -> 1, nd - N)...))
A = cat_similar(as[1], T, (ntuple(d -> size(as[1], d), N - 1)..., Ndim, ntuple(Returns(1), nd - N)...))
k = 1
for a ∈ as
for i ∈ eachindex(a)
Expand All @@ -2450,7 +2450,7 @@ function _typed_hvncat(::Type{T}, ::Val{N}, as...) where {T, N}
end
end

A = Array{T, nd}(undef, ntuple(x -> 1, Val(N - 1))..., Ndim, ntuple(x -> 1, nd - N)...)
A = Array{T, nd}(undef, ntuple(Returns(1), Val(N - 1))..., Ndim, ntuple(Returns(1), nd - N)...)

k = 1
for a ∈ as
Expand Down Expand Up @@ -2518,7 +2518,7 @@ function hvncat_fill!(A::Array, row_first::Bool, xs::Tuple)
dd = nrc * (d - 1)
for i ∈ 1:nr
Ai = dd + i
for j ∈ 1:nc
for _ ∈ 1:nc
@inbounds A[Ai] = xs[k]
k += 1
Ai += nr
Expand All @@ -2535,7 +2535,7 @@ end
function _typed_hvncat(T::Type, dims::NTuple{N, Int}, row_first::Bool, as...) where {N}
# function barrier after calculating the max is necessary for high performance
nd = max(maximum(cat_ndims(a) for a ∈ as), N)
return _typed_hvncat_dims(T, (dims..., ntuple(x -> 1, nd - N)...), row_first, as)
return _typed_hvncat_dims(T, (dims..., ntuple(Returns(1), nd - N)...), row_first, as)
end

function _typed_hvncat_dims(::Type{T}, dims::NTuple{N, Int}, row_first::Bool, as::Tuple) where {T, N}
Expand Down Expand Up @@ -2644,7 +2644,7 @@ end
function _typed_hvncat(T::Type, shape::NTuple{N, Tuple}, row_first::Bool, as...) where {N}
# function barrier after calculating the max is necessary for high performance
nd = max(maximum(cat_ndims(a) for a ∈ as), N)
return _typed_hvncat_shape(T, (shape..., ntuple(x -> shape[end], nd - N)...), row_first, as)
return _typed_hvncat_shape(T, (shape..., ntuple(Returns(shape[end]), nd - N)...), row_first, as)
end

function _typed_hvncat_shape(::Type{T}, shape::NTuple{N, Tuple}, row_first, as::Tuple) where {T, N}
Expand Down Expand Up @@ -2976,8 +2976,8 @@ _vec_axis(A, ax=_iterator_axes(A)) = length(ax) == 1 ? only(ax) : OneTo(prod(len
end

function _dim_stack!(::Val{dims}, B::AbstractArray, x1, xrest) where {dims}
before = ntuple(d -> Colon(), dims - 1)
after = ntuple(d -> Colon(), ndims(B) - dims)
before = ntuple(Returns(Colon()), dims - 1)
after = ntuple(Returns(Colon()), ndims(B) - dims)

i = firstindex(B, dims)
copyto!(view(B, before..., i, after...), x1)
Expand Down Expand Up @@ -3165,8 +3165,7 @@ _sub2ind_vec(i, I1, I...) = (@inline; (I1[i], _sub2ind_vec(i, I...)...))
_sub2ind_vec(i) = ()

function _ind2sub(inds::Union{DimsInteger{N},Indices{N}}, ind::AbstractVector{<:Integer}) where N
M = length(ind)
t = ntuple(n->similar(ind),Val(N))
t = ntuple(_->similar(ind),Val(N))
for (i,idx) in pairs(IndexLinear(), ind)
sub = _ind2sub(inds, idx)
for j = 1:N
Expand Down
4 changes: 0 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,6 @@ function _growbeg!(a::Vector, delta::Integer)
delta == 0 && return # avoid attempting to index off the end
delta >= 0 || throw(ArgumentError("grow requires delta >= 0"))
ref = a.ref
mem = ref.mem
len = length(a)
offset = memoryrefoffset(ref)
newlen = len + delta
Expand Down Expand Up @@ -1420,7 +1419,6 @@ append!(a::AbstractVector, iter...) = (foreach(v -> append!(a, v), iter); a)

function _append!(a::AbstractVector, ::Union{HasLength,HasShape}, iter)
n = Int(length(iter))::Int
i = lastindex(a)
sizehint!(a, length(a) + n; shrink=false)
for item in iter
push!(a, item)
Expand Down Expand Up @@ -1764,7 +1762,6 @@ function pushfirst!(a::Vector{Any}, @nospecialize x)
end
function pushfirst!(a::Vector{Any}, @nospecialize x...)
@_terminates_locally_meta
na = length(a)
nx = length(x)
_growbeg!(a, nx)
@_safeindex for i = 1:nx
Expand Down Expand Up @@ -1878,7 +1875,6 @@ function deleteat!(a::Vector, r::AbstractUnitRange{<:Integer})
if eltype(r) === Bool
return invoke(deleteat!, Tuple{Vector, AbstractVector{Bool}}, a, r)
else
n = length(a)
f = first(r)
f isa Bool && depwarn("passing Bool as an index is deprecated", :deleteat!)
isempty(r) || _deleteat!(a, f, length(r))
Expand Down
2 changes: 1 addition & 1 deletion base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end
@inbounds if (olds[i] & 0x80) != 0
k = oldk[i]
v = oldv[i]
index, sh = hashindex(k, newsz)
index, _ = hashindex(k, newsz)
index0 = index
while slots[index] != 0
index = (index & (newsz-1)) + 1
Expand Down
18 changes: 9 additions & 9 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,10 @@ function checkbounds(A::Union{Array, GenericMemory}, i::Int)
checkbounds(Bool, A, i) || throw_boundserror(A, (i,))
end

default_access_order(a::GenericMemory{:not_atomic}) = :not_atomic
default_access_order(a::GenericMemory{:atomic}) = :monotonic
default_access_order(a::GenericMemoryRef{:not_atomic}) = :not_atomic
default_access_order(a::GenericMemoryRef{:atomic}) = :monotonic
default_access_order(::GenericMemory{:not_atomic}) = :not_atomic
default_access_order(::GenericMemory{:atomic}) = :monotonic
default_access_order(::GenericMemoryRef{:not_atomic}) = :not_atomic
default_access_order(::GenericMemoryRef{:atomic}) = :monotonic

function getindex(A::GenericMemory, i::Int)
@_noub_if_noinbounds_meta
Expand Down Expand Up @@ -464,7 +464,7 @@ See also: [`round`](@ref), [`trunc`](@ref), [`oftype`](@ref), [`reinterpret`](@r
function convert end

# ensure this is never ambiguous, and therefore fast for lookup
convert(T::Type{Union{}}, x...) = throw(ArgumentError("cannot convert a value to Union{} for assignment"))
convert(::Type{Union{}}, _...) = throw(ArgumentError("cannot convert a value to Union{} for assignment"))

convert(::Type{Type}, x::Type) = x # the ssair optimizer is strongly dependent on this method existing to avoid over-specialization
# in the absence of inlining-enabled
Expand Down Expand Up @@ -513,7 +513,7 @@ Modifying the key-space of the underlying data may invalidate this object.
"""
Pairs

argtail(x, rest...) = rest
argtail(_, rest...) = rest

"""
tail(x::Tuple)::Tuple
Expand Down Expand Up @@ -576,7 +576,7 @@ end

# remove concrete constraint on diagonal TypeVar if it comes from troot
function widen_diagonal(@nospecialize(t), troot::UnionAll)
body = ccall(:jl_widen_diagonal, Any, (Any, Any), t, troot)
return ccall(:jl_widen_diagonal, Any, (Any, Any), t, troot)
end

function isvarargtype(@nospecialize(t))
Expand Down Expand Up @@ -981,7 +981,7 @@ getindex(v::SimpleVector, i::Int) = (@_foldable_meta; Core._svec_ref(v, i))
function length(v::SimpleVector)
Core._svec_len(v)
end
firstindex(v::SimpleVector) = 1
firstindex(::SimpleVector) = 1
lastindex(v::SimpleVector) = length(v)
iterate(v::SimpleVector, i=1) = (length(v) < i ? nothing : (v[i], i + 1))
eltype(::Type{SimpleVector}) = Any
Expand Down Expand Up @@ -1229,7 +1229,7 @@ to obtain a definitive answer.

See also [`iterate`](@ref), [`isempty`](@ref)
"""
isdone(itr, state...) = missing
isdone(_, _...) = missing

"""
iterate(iter [, state])::Union{Nothing, Tuple{Any, Any}}
Expand Down
4 changes: 2 additions & 2 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ orderings such as [`isless`](@ref).
!!! compat "Julia 1.7"
This function requires Julia 1.7 or later.
"""
isunordered(x) = false
isunordered(_) = false
isunordered(x::AbstractFloat) = isnan(x)
isunordered(x::Missing) = true
isunordered(::Missing) = true

==(T::Type, S::Type) = (@_total_meta; ccall(:jl_types_equal, Cint, (Any, Any), T, S) != 0)
==(T::TypeVar, S::Type) = false
Expand Down
Loading