Skip to content

Commit

Permalink
Replace Array{...}(shape...)-like calls in base/[e-k]*.jl. (JuliaLang…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 authored and fredrikekre committed Nov 25, 2017
1 parent 6fa2047 commit 9c9eb68
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion base/Enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ macro enum(T, syms...)
elseif !isa(T, Symbol)
throw(ArgumentError("invalid type expression for enum $T"))
end
vals = Vector{Tuple{Symbol,Integer}}(0)
vals = Vector{Tuple{Symbol,Integer}}()
lo = hi = 0
i = zero(basetype)
hasexpr = false
Expand Down
2 changes: 1 addition & 1 deletion base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if Sys.iswindows()
pos = block[1]
blk = block[2]
len = ccall(:wcslen, UInt, (Ptr{UInt16},), pos)
buf = Vector{UInt16}(len)
buf = Vector{UInt16}(uninitialized, len)
@gc_preserve buf unsafe_copy!(pointer(buf), pos, len)
env = transcode(String, buf)
m = match(r"^(=?[^=]+)=(.*)$"s, env)
Expand Down
2 changes: 1 addition & 1 deletion base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ end

# convert dual arrays (ips, interpreter_frames) to a single array of locations
function _reformat_bt(bt, bt2)
ret = Array{Union{InterpreterIP,Ptr{Void}},1}()
ret = Vector{Union{InterpreterIP,Ptr{Void}}}()
i, j = 1, 1
while i <= length(bt)
ip = bt[i]::Ptr{Void}
Expand Down
8 changes: 4 additions & 4 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function append_any(xs...)
# used by apply() and quote
# must be a separate function from append(), since apply() needs this
# exact function.
out = Vector{Any}(4)
out = Vector{Any}(uninitialized, 4)
l = 4
i = 1
for x in xs
Expand Down Expand Up @@ -627,7 +627,7 @@ Val(x) = (@_pure_meta; Val{x}())
# used by keyword arg call lowering
function vector_any(@nospecialize xs...)
n = length(xs)
a = Vector{Any}(n)
a = Vector{Any}(uninitialized, n)
@inbounds for i = 1:n
Core.arrayset(false, a, xs[i], i)
end
Expand All @@ -636,7 +636,7 @@ end

function as_kwargs(xs::Union{AbstractArray,Associative})
n = length(xs)
to = Vector{Any}(n*2)
to = Vector{Any}(uninitialized, n*2)
i = 1
for (k, v) in xs
to[i] = k::Symbol
Expand All @@ -647,7 +647,7 @@ function as_kwargs(xs::Union{AbstractArray,Associative})
end

function as_kwargs(xs)
to = Vector{Any}(0)
to = Vector{Any}()
for (k, v) in xs
ccall(:jl_array_ptr_1d_push2, Void, (Any, Any, Any), to, k::Symbol, v)
end
Expand Down
10 changes: 5 additions & 5 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export
Get the current working directory.
"""
function pwd()
b = Vector{UInt8}(1024)
b = Vector{UInt8}(uninitialized, 1024)
len = Ref{Csize_t}(length(b))
uv_error(:getcwd, ccall(:uv_cwd, Cint, (Ptr{UInt8}, Ptr{Csize_t}), b, len))
String(b[1:len[]])
Expand Down Expand Up @@ -257,7 +257,7 @@ end
if Sys.iswindows()

function tempdir()
temppath = Vector{UInt16}(32767)
temppath = Vector{UInt16}(uninitialized, 32767)
lentemppath = ccall(:GetTempPathW,stdcall,UInt32,(UInt32,Ptr{UInt16}),length(temppath),temppath)
if lentemppath >= length(temppath) || lentemppath == 0
error("GetTempPath failed: $(Libc.FormatMessage())")
Expand All @@ -269,7 +269,7 @@ tempname(uunique::UInt32=UInt32(0)) = tempname(tempdir(), uunique)
const temp_prefix = cwstring("jl_")
function tempname(temppath::AbstractString,uunique::UInt32)
tempp = cwstring(temppath)
tname = Vector{UInt16}(32767)
tname = Vector{UInt16}(uninitialized, 32767)
uunique = ccall(:GetTempFileNameW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32,Ptr{UInt16}), tempp,temp_prefix,uunique,tname)
lentname = findfirst(iszero,tname)-1
if uunique == 0 || lentname <= 0
Expand Down Expand Up @@ -465,8 +465,8 @@ function walkdir(root; topdown=true, follow_symlinks=false, onerror=throw)
close(chnl)
return chnl
end
dirs = Vector{eltype(content)}(0)
files = Vector{eltype(content)}(0)
dirs = Vector{eltype(content)}()
files = Vector{eltype(content)}()
for name in content
if isdir(joinpath(root, name))
push!(dirs, name)
Expand Down
4 changes: 2 additions & 2 deletions base/float.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ end
# "Fast Half Float Conversion" by Jeroen van der Zijp
# ftp:https://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf

const basetable = Vector{UInt16}(512)
const shifttable = Vector{UInt8}(512)
const basetable = Vector{UInt16}(uninitialized, 512)
const shifttable = Vector{UInt8}(uninitialized, 512)

for i = 0:255
e = i - 127
Expand Down
2 changes: 1 addition & 1 deletion base/grisu/bignums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mutable struct Bignum
used_digits::Int32
exponent::Int32
function Bignum()
bigits = Vector{UInt32}(kBigitCapacity)
bigits = Vector{UInt32}(uninitialized, kBigitCapacity)
@inbounds for i = 1:kBigitCapacity
bigits[i] = 0
end
Expand Down
2 changes: 1 addition & 1 deletion base/grisu/fastprecision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function digitgen(w,buffer,requested_digits=1000)
return r, kappa, len
end

function fastprecision(v, requested_digits, buffer = Vector{UInt8}(100))
function fastprecision(v, requested_digits, buffer = Vector{UInt8}(uninitialized, 100))
f = normalize(Float64(v))
ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize)
ten_mk_max_exp = kMaxExp - (f.e + FloatSignificandSize)
Expand Down
2 changes: 1 addition & 1 deletion base/grisu/fastshortest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function digitgen(low,w,high,buffer)
end
end

function fastshortest(v, buffer = Vector{UInt8}(17))
function fastshortest(v, buffer = Vector{UInt8}(uninitialized, 17))
f = normalize(Float64(v))
bound_minus, bound_plus = normalizedbound(v)
ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize)
Expand Down
2 changes: 1 addition & 1 deletion base/grisu/grisu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const SHORTEST = 1
const FIXED = 2
const PRECISION = 3

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

include(joinpath("grisu", "float.jl"))
include(joinpath("grisu", "fastshortest.jl"))
Expand Down
20 changes: 10 additions & 10 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,11 @@ iskindtype(@nospecialize t) = (t === DataType || t === UnionAll || t === Union |

const IInf = typemax(Int) # integer infinity
const n_ifunc = reinterpret(Int32, arraylen) + 1
const t_ifunc = Array{Tuple{Int, Int, Any}, 1}(n_ifunc)
const t_ifunc_cost = Array{Int, 1}(n_ifunc)
const t_ffunc_key = Array{Any, 1}(0)
const t_ffunc_val = Array{Tuple{Int, Int, Any}, 1}(0)
const t_ffunc_cost = Array{Int, 1}(0)
const t_ifunc = Vector{Tuple{Int, Int, Any}}(uninitialized, n_ifunc)
const t_ifunc_cost = Vector{Int}(uninitialized, n_ifunc)
const t_ffunc_key = Vector{Any}()
const t_ffunc_val = Vector{Tuple{Int, Int, Any}}()
const t_ffunc_cost = Vector{Int}()
function add_tfunc(f::IntrinsicFunction, minarg::Int, maxarg::Int, @nospecialize(tfunc), cost::Int)
idx = reinterpret(Int32, f) + 1
t_ifunc[idx] = (minarg, maxarg, tfunc)
Expand Down Expand Up @@ -4260,7 +4260,7 @@ function linearize_args!(args::Vector{Any}, atypes::Vector{Any}, stmts::Vector{A
# linearize the IR by moving the arguments to SSA position
na = length(args)
@assert length(atypes) == na
newargs = Vector{Any}(na)
newargs = Vector{Any}(uninitialized, na)
for i = na:-1:1
aei = args[i]
ti = atypes[i]
Expand Down Expand Up @@ -5272,7 +5272,7 @@ function inlining_pass(e::Expr, sv::OptimizationState, stmts::Vector{Any}, ins,
end

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

if f === _apply
na = length(e.args)
newargs = Vector{Any}(na-2)
newargs = Vector{Any}(uninitialized, na-2)
newstmts = Any[]
effect_free_upto = 0
for i = 3:na
Expand Down Expand Up @@ -6025,10 +6025,10 @@ function alloc_elim_pass!(sv::OptimizationState)
end
end
else
vals = Vector{Any}(nv)
vals = Vector{Any}(uninitialized, nv)
local new_slots::Vector{Int}
if !is_ssa
new_slots = Vector{Int}(nv)
new_slots = Vector{Int}(uninitialized, nv)
end
for j=1:nv
tupelt = tup[j+1]
Expand Down
4 changes: 2 additions & 2 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ Read at most `nb` bytes from `s`, returning a `Vector{UInt8}` of the bytes read.
function read(s::IO, nb::Integer = typemax(Int))
# Let readbytes! grow the array progressively by default
# instead of taking of risk of over-allocating
b = Vector{UInt8}(nb == typemax(Int) ? 1024 : nb)
b = Vector{UInt8}(uninitialized, nb == typemax(Int) ? 1024 : nb)
nr = readbytes!(s, b, nb)
return resize!(b, nr)
end
Expand Down Expand Up @@ -791,7 +791,7 @@ passing them as the second argument.
function countlines(io::IO, eol::Char='\n')
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
aeol = UInt8(eol)
a = Vector{UInt8}(8192)
a = Vector{UInt8}(uninitialized, 8192)
nl = 0
while !eof(io)
nb = readbytes!(io, a)
Expand Down
4 changes: 2 additions & 2 deletions base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ end
# num bytes available without blocking
nb_available(s::IOStream) = ccall(:jl_nb_available, Int32, (Ptr{Void},), s.ios)

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

function read(s::IOStream, ::Type{UInt8})
b = ccall(:ios_getc, Cint, (Ptr{Void},), s.ios)
Expand Down Expand Up @@ -330,7 +330,7 @@ requested bytes, until an error or end-of-file occurs. If `all` is `false`, at m
all stream types support the `all` option.
"""
function read(s::IOStream, nb::Integer; all::Bool=true)
b = Array{UInt8,1}(nb)
b = Vector{UInt8}(uninitialized, nb)
nr = readbytes!(s, b, nb, all=all)
resize!(b, nr)
end
Expand Down
2 changes: 1 addition & 1 deletion base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ function next(itr::PartitionIterator{<:Vector}, state)
end

function next(itr::PartitionIterator, state)
v = Vector{eltype(itr.c)}(itr.n)
v = Vector{eltype(itr.c)}(uninitialized, itr.n)
i = 0
while !done(itr.c, state) && i < itr.n
i += 1
Expand Down
4 changes: 2 additions & 2 deletions base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ getpid() = ccall(:jl_getpid, Int32, ())
Get the local machine's host name.
"""
function gethostname()
hn = Vector{UInt8}(256)
hn = Vector{UInt8}(uninitialized, 256)
err = @static if Sys.iswindows()
ccall(:gethostname, stdcall, Int32, (Ptr{UInt8}, UInt32), hn, length(hn))
else
Expand Down Expand Up @@ -307,7 +307,7 @@ if Sys.iswindows()
C_NULL, e, 0, lpMsgBuf, 0, C_NULL)
p = lpMsgBuf[]
len == 0 && return ""
buf = Vector{UInt16}(len)
buf = Vector{UInt16}(uninitialized, len)
Base.@gc_preserve buf unsafe_copy!(pointer(buf), p, len)
ccall(:LocalFree, stdcall, Ptr{Void}, (Ptr{Void},), p)
return transcode(String, buf)
Expand Down
2 changes: 1 addition & 1 deletion base/libdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ if Sys.isbsd() && !Sys.isapple()
end # bsd family

function dllist()
dynamic_libraries = Vector{AbstractString}(0)
dynamic_libraries = Vector{AbstractString}()

@static if Sys.islinux()
callback = cfunction(dl_phdr_info_callback, Cint,
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ function Base.map(f::Function, bi::GitBranchIter)
while !done(bi, s)
val = f(s[1:2])
if res === nothing
res = Vector{typeof(val)}(0)
res = Vector{typeof(val)}()
end
push!(res, val)
val, s = next(bi, s)
Expand Down

0 comments on commit 9c9eb68

Please sign in to comment.