diff --git a/base/bitarray.jl b/base/bitarray.jl index a6d94b2152a39..3d2267bc49f00 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -22,7 +22,7 @@ mutable struct BitArray{N} <: DenseArray{Bool, N} i += 1 end nc = num_bit_chunks(n) - chunks = Vector{UInt64}(nc) + chunks = Vector{UInt64}(uninitialized, nc) nc > 0 && (chunks[end] = UInt64(0)) b = new(chunks, n) N != 1 && (b.dims = dims) @@ -348,7 +348,7 @@ similar(B::BitArray, dims::Dims) = BitArray(dims...) similar(B::BitArray, T::Type{Bool}, dims::Dims) = BitArray(dims) # changing type to a non-Bool returns an Array # (this triggers conversions like float(bitvector) etc.) -similar(B::BitArray, T::Type, dims::Dims) = Array{T}(dims) +similar(B::BitArray, T::Type, dims::Dims) = Array{T}(uninitialized, dims) function fill!(B::BitArray, x) y = convert(Bool, x) @@ -502,7 +502,7 @@ end convert(::Type{Array{T}}, B::BitArray{N}) where {T,N} = convert(Array{T,N}, B) convert(::Type{Array{T,N}}, B::BitArray{N}) where {T,N} = _convert(Array{T,N}, B) # see #15801 function _convert(::Type{Array{T,N}}, B::BitArray{N}) where {T,N} - A = Array{T}(size(B)) + A = Array{T}(uninitialized, size(B)) Bc = B.chunks @inbounds for i = 1:length(A) A[i] = unsafe_bitgetindex(Bc, i) @@ -620,7 +620,7 @@ gen_bitarray(::IsInfinite, itr) = throw(ArgumentError("infinite-size iterable u function gen_bitarray_from_itr(itr, st) B = empty!(BitArray(bitcache_size)) - C = Vector{Bool}(bitcache_size) + C = Vector{Bool}(uninitialized, bitcache_size) Bc = B.chunks ind = 1 cind = 1 @@ -645,7 +645,7 @@ end function fill_bitarray_from_itr!(B::BitArray, itr, st) n = length(B) - C = Vector{Bool}(bitcache_size) + C = Vector{Bool}(uninitialized, bitcache_size) Bc = B.chunks ind = 1 cind = 1 @@ -1189,7 +1189,7 @@ end for f in (:+, :-) @eval function ($f)(A::BitArray, B::BitArray) - r = Array{Int}(promote_shape(size(A), size(B))) + r = Array{Int}(uninitialized, promote_shape(size(A), size(B))) ai = start(A) bi = start(B) ri = 1 @@ -1649,7 +1649,7 @@ end function find(B::BitArray) l = length(B) nnzB = count(B) - I = Vector{Int}(nnzB) + I = Vector{Int}(uninitialized, nnzB) nnzB == 0 && return I Bc = B.chunks Bcount = 1 @@ -1683,8 +1683,8 @@ findn(B::BitVector) = find(B) function findn(B::BitMatrix) nnzB = count(B) - I = Vector{Int}(nnzB) - J = Vector{Int}(nnzB) + I = Vector{Int}(uninitialized, nnzB) + J = Vector{Int}(uninitialized, nnzB) cnt = 1 for j = 1:size(B,2), i = 1:size(B,1) if B[i,j] diff --git a/base/broadcast.jl b/base/broadcast.jl index f81b16672e788..ffa047e94c367 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -168,7 +168,7 @@ end @nexprs $N i->(A_{i+1} = Bs[i]) @nexprs $nargs i->(keep_i = keeps[i]) @nexprs $nargs i->(Idefault_i = Idefaults[i]) - C = Vector{Bool}(bitcache_size) + C = Vector{Bool}(uninitialized, bitcache_size) Bc = B.chunks ind = 1 cind = 1 diff --git a/base/channels.jl b/base/channels.jl index c6cad87c5f369..b48a8d0cf91be 100644 --- a/base/channels.jl +++ b/base/channels.jl @@ -42,10 +42,10 @@ mutable struct Channel{T} <: AbstractChannel if sz < 0 throw(ArgumentError("Channel size must be either 0, a positive integer or Inf")) end - ch = new(Condition(), Condition(), :open, Nullable{Exception}(), Vector{T}(0), sz, 0) + ch = new(Condition(), Condition(), :open, Nullable{Exception}(), Vector{T}(), sz, 0) if sz == 0 - ch.takers = Vector{Task}(0) - ch.putters = Vector{Task}(0) + ch.takers = Vector{Task}() + ch.putters = Vector{Task}() end return ch end diff --git a/base/combinatorics.jl b/base/combinatorics.jl index ad38a7fd07538..7b8b79fc16bfd 100644 --- a/base/combinatorics.jl +++ b/base/combinatorics.jl @@ -2,13 +2,13 @@ # Factorials -const _fact_table64 = Vector{Int64}(20) +const _fact_table64 = Vector{Int64}(uninitialized, 20) _fact_table64[1] = 1 for n in 2:20 _fact_table64[n] = _fact_table64[n-1] * n end -const _fact_table128 = Vector{UInt128}(34) +const _fact_table128 = Vector{UInt128}(uninitialized, 34) _fact_table128[1] = 1 for n in 2:34 _fact_table128[n] = _fact_table128[n-1] * n diff --git a/base/deprecated.jl b/base/deprecated.jl index 18e9ee6d93d41..e8cc748edfe32 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -792,7 +792,7 @@ function Math.frexp(A::Array{<:AbstractFloat}) "consider using dot-syntax to `broadcast` scalar `frexp` over `Array`s ", "instead, for example `frexp.(rand(4))`."), :frexp) F = similar(A) - E = Array{Int}(size(A)) + E = Array{Int}(uninitialized, size(A)) for (iF, iE, iA) in zip(eachindex(F), eachindex(E), eachindex(A)) F[iF], E[iE] = frexp(A[iA]) end @@ -931,15 +931,15 @@ iteratoreltype(::Type{Task}) = EltypeUnknown() isempty(::Task) = error("isempty not defined for Tasks") # Deprecate Array(T, dims...) in favor of proper type constructors -@deprecate Array(::Type{T}, d::NTuple{N,Int}) where {T,N} Array{T}(d) -@deprecate Array(::Type{T}, d::Int...) where {T} Array{T}(d...) -@deprecate Array(::Type{T}, m::Int) where {T} Array{T}(m) -@deprecate Array(::Type{T}, m::Int,n::Int) where {T} Array{T}(m,n) -@deprecate Array(::Type{T}, m::Int,n::Int,o::Int) where {T} Array{T}(m,n,o) -@deprecate Array(::Type{T}, d::Integer...) where {T} Array{T}(convert(Tuple{Vararg{Int}}, d)) -@deprecate Array(::Type{T}, m::Integer) where {T} Array{T}(Int(m)) -@deprecate Array(::Type{T}, m::Integer,n::Integer) where {T} Array{T}(Int(m),Int(n)) -@deprecate Array(::Type{T}, m::Integer,n::Integer,o::Integer) where {T} Array{T}(Int(m),Int(n),Int(o)) +@deprecate Array(::Type{T}, d::NTuple{N,Int}) where {T,N} Array{T}(uninitialized, d) +@deprecate Array(::Type{T}, d::Int...) where {T} Array{T}(uninitialized, d...) +@deprecate Array(::Type{T}, m::Int) where {T} Array{T}(uninitialized, m) +@deprecate Array(::Type{T}, m::Int,n::Int) where {T} Array{T}(uninitialized, m,n) +@deprecate Array(::Type{T}, m::Int,n::Int,o::Int) where {T} Array{T}(uninitialized, m,n,o) +@deprecate Array(::Type{T}, d::Integer...) where {T} Array{T}(uninitialized, convert(Tuple{Vararg{Int}}, d)) +@deprecate Array(::Type{T}, m::Integer) where {T} Array{T}(uninitialized, Int(m)) +@deprecate Array(::Type{T}, m::Integer,n::Integer) where {T} Array{T}(uninitialized, Int(m),Int(n)) +@deprecate Array(::Type{T}, m::Integer,n::Integer,o::Integer) where {T} Array{T}(uninitialized, Int(m),Int(n),Int(o)) @noinline function is_intrinsic_expr(@nospecialize(x)) Base.depwarn("is_intrinsic_expr is deprecated. There are no intrinsic functions anymore.", :is_intrinsic_expr) @@ -1062,14 +1062,14 @@ end ## end of FloatRange @noinline zero_arg_matrix_constructor(prefix::String) = - depwarn("$prefix() is deprecated, use $prefix(0, 0) instead.", :zero_arg_matrix_constructor) + depwarn("$prefix() is deprecated, use $prefix(uninitialized, 0, 0) instead.", :zero_arg_matrix_constructor) function Matrix{T}() where T zero_arg_matrix_constructor("Matrix{T}") - return Matrix{T}(0, 0) + return Matrix{T}(uninitialized, 0, 0) end function Matrix() zero_arg_matrix_constructor("Matrix") - return Matrix(0, 0) + return Matrix(uninitialized, 0, 0) end for name in ("alnum", "alpha", "cntrl", "digit", "number", "graph", @@ -1129,9 +1129,9 @@ import .LinAlg: cond # PR #21359 import .Random: srand -@deprecate srand(r::MersenneTwister, filename::AbstractString, n::Integer=4) srand(r, read!(filename, Array{UInt32}(Int(n)))) -@deprecate srand(filename::AbstractString, n::Integer=4) srand(read!(filename, Array{UInt32}(Int(n)))) -@deprecate MersenneTwister(filename::AbstractString) srand(MersenneTwister(0), read!(filename, Array{UInt32}(Int(4)))) +@deprecate srand(r::MersenneTwister, filename::AbstractString, n::Integer=4) srand(r, read!(filename, Vector{UInt32}(uninitialized, Int(n)))) +@deprecate srand(filename::AbstractString, n::Integer=4) srand(read!(filename, Vector{UInt32}(uninitialized, Int(n)))) +@deprecate MersenneTwister(filename::AbstractString) srand(MersenneTwister(0), read!(filename, Vector{UInt32}(uninitialized, Int(4)))) # PR #21974 @deprecate versioninfo(verbose::Bool) versioninfo(verbose=verbose) @@ -1343,9 +1343,9 @@ import .LinAlg: lufact, lufact!, qrfact, qrfact!, cholfact, cholfact! @deprecate read(s::IO, x::Ref) read!(s, x) -@deprecate read(s::IO, t::Type, d1::Int, dims::Int...) read!(s, Array{t}(tuple(d1,dims...))) -@deprecate read(s::IO, t::Type, d1::Integer, dims::Integer...) read!(s, Array{t}(convert(Tuple{Vararg{Int}},tuple(d1,dims...)))) -@deprecate read(s::IO, t::Type, dims::Dims) read!(s, Array{t}(dims)) +@deprecate read(s::IO, t::Type, d1::Int, dims::Int...) read!(s, Array{t}(uninitialized, tuple(d1,dims...))) +@deprecate read(s::IO, t::Type, d1::Integer, dims::Integer...) read!(s, Array{t}(uninitialized, convert(Tuple{Vararg{Int}},tuple(d1,dims...)))) +@deprecate read(s::IO, t::Type, dims::Dims) read!(s, Array{t}(uninitialized, dims)) function CartesianRange(start::CartesianIndex{N}, stop::CartesianIndex{N}) where N inds = map((f,l)->f:l, start.I, stop.I) diff --git a/base/dict.jl b/base/dict.jl index 1f8be1c375aee..4a3ed1352e5fa 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -101,7 +101,7 @@ mutable struct Dict{K,V} <: Associative{K,V} function Dict{K,V}() where V where K n = 16 - new(zeros(UInt8,n), Array{K,1}(n), Array{V,1}(n), 0, 0, 0, 1, 0) + new(zeros(UInt8,n), Vector{K}(uninitialized, n), Vector{V}(uninitialized, n), 0, 0, 0, 1, 0) end function Dict{K,V}(d::Dict{K,V}) where V where K new(copy(d.slots), copy(d.keys), copy(d.vals), d.ndel, d.count, d.age, @@ -227,8 +227,8 @@ function rehash!(h::Dict{K,V}, newsz = length(h.keys)) where V where K end slots = zeros(UInt8,newsz) - keys = Array{K,1}(newsz) - vals = Array{V,1}(newsz) + keys = Vector{K}(uninitialized, newsz) + vals = Vector{V}(uninitialized, newsz) age0 = h.age count = 0 maxprobe = h.maxprobe diff --git a/base/docs/core.jl b/base/docs/core.jl index b096bf13173aa..b428ae7269ec5 100644 --- a/base/docs/core.jl +++ b/base/docs/core.jl @@ -7,7 +7,7 @@ import ..esc, ..push!, ..getindex, ..unsafe_load, ..Csize_t function doc!(source::LineNumberNode, mod::Module, str, ex) push!(DOCS, (mod, ex, str, source.file, source.line)) end -const DOCS = Array{Any, 1}() +const DOCS = Array{Any,1}() isexpr(x, h) = isa(x, Expr) && x.head === h diff --git a/base/docs/utils.jl b/base/docs/utils.jl index 5daaa068a7893..b4a1f4eb947ec 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -271,7 +271,7 @@ function levenshtein(s1, s2) a, b = collect(s1), collect(s2) m = length(a) n = length(b) - d = Matrix{Int}(m+1, n+1) + d = Matrix{Int}(uninitialized, m+1, n+1) d[1:m+1, 1] = 0:m d[1, 1:n+1] = 0:n