Skip to content

Commit f66da09

Browse files
committed
Replace Array{...}(shape...)-like calls in base/[e-k]*.jl.
1 parent 2b326d3 commit f66da09

17 files changed

+37
-37
lines changed

base/Enums.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ macro enum(T, syms...)
6565
elseif !isa(T, Symbol)
6666
throw(ArgumentError("invalid type expression for enum $T"))
6767
end
68-
vals = Vector{Tuple{Symbol,Integer}}(0)
68+
vals = Vector{Tuple{Symbol,Integer}}()
6969
lo = hi = 0
7070
i = zero(basetype)
7171
hasexpr = false

base/env.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ if Sys.iswindows()
9898
pos = block[1]
9999
blk = block[2]
100100
len = ccall(:wcslen, UInt, (Ptr{UInt16},), pos)
101-
buf = Vector{UInt16}(len)
101+
buf = Vector{UInt16}(uninitialized, len)
102102
@gc_preserve buf unsafe_copy!(pointer(buf), pos, len)
103103
env = transcode(String, buf)
104104
m = match(r"^(=?[^=]+)=(.*)$"s, env)

base/error.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ end
6060

6161
# convert dual arrays (ips, interpreter_frames) to a single array of locations
6262
function _reformat_bt(bt, bt2)
63-
ret = Array{Union{InterpreterIP,Ptr{Void}},1}()
63+
ret = Vector{Union{InterpreterIP,Ptr{Void}}}()
6464
i, j = 1, 1
6565
while i <= length(bt)
6666
ip = bt[i]::Ptr{Void}

base/essentials.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ function append_any(xs...)
370370
# used by apply() and quote
371371
# must be a separate function from append(), since apply() needs this
372372
# exact function.
373-
out = Vector{Any}(4)
373+
out = Vector{Any}(uninitialized, 4)
374374
l = 4
375375
i = 1
376376
for x in xs
@@ -627,7 +627,7 @@ Val(x) = (@_pure_meta; Val{x}())
627627
# used by keyword arg call lowering
628628
function vector_any(@nospecialize xs...)
629629
n = length(xs)
630-
a = Vector{Any}(n)
630+
a = Vector{Any}(uninitialized, n)
631631
@inbounds for i = 1:n
632632
Core.arrayset(false, a, xs[i], i)
633633
end
@@ -636,7 +636,7 @@ end
636636

637637
function as_kwargs(xs::Union{AbstractArray,Associative})
638638
n = length(xs)
639-
to = Vector{Any}(n*2)
639+
to = Vector{Any}(uninitialized, n*2)
640640
i = 1
641641
for (k, v) in xs
642642
to[i] = k::Symbol
@@ -647,7 +647,7 @@ function as_kwargs(xs::Union{AbstractArray,Associative})
647647
end
648648

649649
function as_kwargs(xs)
650-
to = Vector{Any}(0)
650+
to = Vector{Any}()
651651
for (k, v) in xs
652652
ccall(:jl_array_ptr_1d_push2, Void, (Any, Any, Any), to, k::Symbol, v)
653653
end

base/file.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export
3535
Get the current working directory.
3636
"""
3737
function pwd()
38-
b = Vector{UInt8}(1024)
38+
b = Vector{UInt8}(uninitialized, 1024)
3939
len = Ref{Csize_t}(length(b))
4040
uv_error(:getcwd, ccall(:uv_cwd, Cint, (Ptr{UInt8}, Ptr{Csize_t}), b, len))
4141
String(b[1:len[]])
@@ -257,7 +257,7 @@ end
257257
if Sys.iswindows()
258258

259259
function tempdir()
260-
temppath = Vector{UInt16}(32767)
260+
temppath = Vector{UInt16}(uninitialized, 32767)
261261
lentemppath = ccall(:GetTempPathW,stdcall,UInt32,(UInt32,Ptr{UInt16}),length(temppath),temppath)
262262
if lentemppath >= length(temppath) || lentemppath == 0
263263
error("GetTempPath failed: $(Libc.FormatMessage())")
@@ -269,7 +269,7 @@ tempname(uunique::UInt32=UInt32(0)) = tempname(tempdir(), uunique)
269269
const temp_prefix = cwstring("jl_")
270270
function tempname(temppath::AbstractString,uunique::UInt32)
271271
tempp = cwstring(temppath)
272-
tname = Vector{UInt16}(32767)
272+
tname = Vector{UInt16}(uninitialized, 32767)
273273
uunique = ccall(:GetTempFileNameW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32,Ptr{UInt16}), tempp,temp_prefix,uunique,tname)
274274
lentname = findfirst(iszero,tname)-1
275275
if uunique == 0 || lentname <= 0
@@ -465,8 +465,8 @@ function walkdir(root; topdown=true, follow_symlinks=false, onerror=throw)
465465
close(chnl)
466466
return chnl
467467
end
468-
dirs = Vector{eltype(content)}(0)
469-
files = Vector{eltype(content)}(0)
468+
dirs = Vector{eltype(content)}()
469+
files = Vector{eltype(content)}()
470470
for name in content
471471
if isdir(joinpath(root, name))
472472
push!(dirs, name)

base/float.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ end
203203
# "Fast Half Float Conversion" by Jeroen van der Zijp
204204
# ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf
205205

206-
const basetable = Vector{UInt16}(512)
207-
const shifttable = Vector{UInt8}(512)
206+
const basetable = Vector{UInt16}(uninitialized, 512)
207+
const shifttable = Vector{UInt8}(uninitialized, 512)
208208

209209
for i = 0:255
210210
e = i - 127

base/grisu/bignums.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ mutable struct Bignum
5454
used_digits::Int32
5555
exponent::Int32
5656
function Bignum()
57-
bigits = Vector{UInt32}(kBigitCapacity)
57+
bigits = Vector{UInt32}(uninitialized, kBigitCapacity)
5858
@inbounds for i = 1:kBigitCapacity
5959
bigits[i] = 0
6060
end

base/grisu/fastprecision.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function digitgen(w,buffer,requested_digits=1000)
8787
return r, kappa, len
8888
end
8989

90-
function fastprecision(v, requested_digits, buffer = Vector{UInt8}(100))
90+
function fastprecision(v, requested_digits, buffer = Vector{UInt8}(uninitialized, 100))
9191
f = normalize(Float64(v))
9292
ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize)
9393
ten_mk_max_exp = kMaxExp - (f.e + FloatSignificandSize)

base/grisu/fastshortest.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function digitgen(low,w,high,buffer)
102102
end
103103
end
104104

105-
function fastshortest(v, buffer = Vector{UInt8}(17))
105+
function fastshortest(v, buffer = Vector{UInt8}(uninitialized, 17))
106106
f = normalize(Float64(v))
107107
bound_minus, bound_plus = normalizedbound(v)
108108
ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize)

base/grisu/grisu.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SHORTEST = 1
99
const FIXED = 2
1010
const PRECISION = 3
1111

12-
const DIGITS = Vector{UInt8}(309+17)
12+
const DIGITS = Vector{UInt8}(uninitialized, 309+17)
1313

1414
include(joinpath("grisu", "float.jl"))
1515
include(joinpath("grisu", "fastshortest.jl"))

base/inference.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,11 @@ iskindtype(@nospecialize t) = (t === DataType || t === UnionAll || t === Union |
511511

512512
const IInf = typemax(Int) # integer infinity
513513
const n_ifunc = reinterpret(Int32, arraylen) + 1
514-
const t_ifunc = Array{Tuple{Int, Int, Any}, 1}(n_ifunc)
515-
const t_ifunc_cost = Array{Int, 1}(n_ifunc)
516-
const t_ffunc_key = Array{Any, 1}(0)
517-
const t_ffunc_val = Array{Tuple{Int, Int, Any}, 1}(0)
518-
const t_ffunc_cost = Array{Int, 1}(0)
514+
const t_ifunc = Vector{Tuple{Int, Int, Any}}(uninitialized, n_ifunc)
515+
const t_ifunc_cost = Vector{Int}(uninitialized, n_ifunc)
516+
const t_ffunc_key = Vector{Any}()
517+
const t_ffunc_val = Vector{Tuple{Int, Int, Any}}()
518+
const t_ffunc_cost = Vector{Int}()
519519
function add_tfunc(f::IntrinsicFunction, minarg::Int, maxarg::Int, @nospecialize(tfunc), cost::Int)
520520
idx = reinterpret(Int32, f) + 1
521521
t_ifunc[idx] = (minarg, maxarg, tfunc)
@@ -4260,7 +4260,7 @@ function linearize_args!(args::Vector{Any}, atypes::Vector{Any}, stmts::Vector{A
42604260
# linearize the IR by moving the arguments to SSA position
42614261
na = length(args)
42624262
@assert length(atypes) == na
4263-
newargs = Vector{Any}(na)
4263+
newargs = Vector{Any}(uninitialized, na)
42644264
for i = na:-1:1
42654265
aei = args[i]
42664266
ti = atypes[i]
@@ -5272,7 +5272,7 @@ function inlining_pass(e::Expr, sv::OptimizationState, stmts::Vector{Any}, ins,
52725272
end
52735273

52745274
for ninline = 1:100
5275-
ata = Vector{Any}(length(e.args))
5275+
ata = Vector{Any}(uninitialized, length(e.args))
52765276
ata[1] = ft
52775277
for i = 2:length(e.args)
52785278
a = exprtype(e.args[i], sv.src, sv.mod)
@@ -5301,7 +5301,7 @@ function inlining_pass(e::Expr, sv::OptimizationState, stmts::Vector{Any}, ins,
53015301

53025302
if f === _apply
53035303
na = length(e.args)
5304-
newargs = Vector{Any}(na-2)
5304+
newargs = Vector{Any}(uninitialized, na-2)
53055305
newstmts = Any[]
53065306
effect_free_upto = 0
53075307
for i = 3:na
@@ -6025,10 +6025,10 @@ function alloc_elim_pass!(sv::OptimizationState)
60256025
end
60266026
end
60276027
else
6028-
vals = Vector{Any}(nv)
6028+
vals = Vector{Any}(uninitialized, nv)
60296029
local new_slots::Vector{Int}
60306030
if !is_ssa
6031-
new_slots = Vector{Int}(nv)
6031+
new_slots = Vector{Int}(uninitialized, nv)
60326032
end
60336033
for j=1:nv
60346034
tupelt = tup[j+1]

base/io.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ Read at most `nb` bytes from `s`, returning a `Vector{UInt8}` of the bytes read.
637637
function read(s::IO, nb::Integer = typemax(Int))
638638
# Let readbytes! grow the array progressively by default
639639
# instead of taking of risk of over-allocating
640-
b = Vector{UInt8}(nb == typemax(Int) ? 1024 : nb)
640+
b = Vector{UInt8}(uninitialized, nb == typemax(Int) ? 1024 : nb)
641641
nr = readbytes!(s, b, nb)
642642
return resize!(b, nr)
643643
end
@@ -791,7 +791,7 @@ passing them as the second argument.
791791
function countlines(io::IO, eol::Char='\n')
792792
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
793793
aeol = UInt8(eol)
794-
a = Vector{UInt8}(8192)
794+
a = Vector{UInt8}(uninitialized, 8192)
795795
nl = 0
796796
while !eof(io)
797797
nb = readbytes!(io, a)

base/iostream.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ end
211211
# num bytes available without blocking
212212
nb_available(s::IOStream) = ccall(:jl_nb_available, Int32, (Ptr{Void},), s.ios)
213213

214-
readavailable(s::IOStream) = read!(s, Vector{UInt8}(nb_available(s)))
214+
readavailable(s::IOStream) = read!(s, Vector{UInt8}(uninitialized, nb_available(s)))
215215

216216
function read(s::IOStream, ::Type{UInt8})
217217
b = ccall(:ios_getc, Cint, (Ptr{Void},), s.ios)
@@ -330,7 +330,7 @@ requested bytes, until an error or end-of-file occurs. If `all` is `false`, at m
330330
all stream types support the `all` option.
331331
"""
332332
function read(s::IOStream, nb::Integer; all::Bool=true)
333-
b = Array{UInt8,1}(nb)
333+
b = Vector{UInt8}(uninitialized, nb)
334334
nr = readbytes!(s, b, nb, all=all)
335335
resize!(b, nr)
336336
end

base/iterators.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ function next(itr::PartitionIterator{<:Vector}, state)
895895
end
896896

897897
function next(itr::PartitionIterator, state)
898-
v = Vector{eltype(itr.c)}(itr.n)
898+
v = Vector{eltype(itr.c)}(uninitialized, itr.n)
899899
i = 0
900900
while !done(itr.c, state) && i < itr.n
901901
i += 1

base/libc.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ getpid() = ccall(:jl_getpid, Int32, ())
245245
Get the local machine's host name.
246246
"""
247247
function gethostname()
248-
hn = Vector{UInt8}(256)
248+
hn = Vector{UInt8}(uninitialized, 256)
249249
err = @static if Sys.iswindows()
250250
ccall(:gethostname, stdcall, Int32, (Ptr{UInt8}, UInt32), hn, length(hn))
251251
else
@@ -307,7 +307,7 @@ if Sys.iswindows()
307307
C_NULL, e, 0, lpMsgBuf, 0, C_NULL)
308308
p = lpMsgBuf[]
309309
len == 0 && return ""
310-
buf = Vector{UInt16}(len)
310+
buf = Vector{UInt16}(uninitialized, len)
311311
Base.@gc_preserve buf unsafe_copy!(pointer(buf), p, len)
312312
ccall(:LocalFree, stdcall, Ptr{Void}, (Ptr{Void},), p)
313313
return transcode(String, buf)

base/libdl.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ if Sys.isbsd() && !Sys.isapple()
234234
end # bsd family
235235

236236
function dllist()
237-
dynamic_libraries = Vector{AbstractString}(0)
237+
dynamic_libraries = Vector{AbstractString}()
238238

239239
@static if Sys.islinux()
240240
callback = cfunction(dl_phdr_info_callback, Cint,

base/libgit2/reference.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ function Base.map(f::Function, bi::GitBranchIter)
350350
while !done(bi, s)
351351
val = f(s[1:2])
352352
if res === nothing
353-
res = Vector{typeof(val)}(0)
353+
res = Vector{typeof(val)}()
354354
end
355355
push!(res, val)
356356
val, s = next(bi, s)

0 commit comments

Comments
 (0)