Skip to content

Commit

Permalink
Update to use Vector and Refs in appropriate files
Browse files Browse the repository at this point in the history
  • Loading branch information
musm committed Apr 16, 2017
1 parent 8934aab commit aa74426
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ function keymap_merge(target,source)
for key in setdiff(keys(source), keys(direct_keys))
# We first resolve redirects in the source
value = source[key]
visited = Array{Any}(0)
visited = Vector{Any}(0)
while isa(value, Union{Char,AbstractString})
value = normalize_key(value)
if value in visited
Expand Down
2 changes: 1 addition & 1 deletion base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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 = Array{UInt8}(8192)
a = Vector{UInt8}(8192)
nl = 0
while !eof(io)
nb = readbytes!(io, a)
Expand Down
6 changes: 3 additions & 3 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 = Array{UInt8}(1024)
b = Vector{UInt8}(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 is_windows()

function tempdir()
temppath = Array{UInt16}(32767)
temppath = Vector{UInt16}(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 = Array{UInt16}(32767)
tname = Vector{UInt16}(32767)
uunique = ccall(:GetTempFileNameW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32,Ptr{UInt16}), tempp,temp_prefix,uunique,tname)
lentname = findfirst(tname,0)-1
if uunique == 0 || lentname <= 0
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 = Array{UInt8}(100))
function fastprecision(v, requested_digits, buffer = Vector{UInt8}(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 = Array{UInt8}(17))
function fastshortest(v, buffer = Vector{UInt8}(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 @@ -11,7 +11,7 @@ const SHORTEST = 1
const FIXED = 2
const PRECISION = 3

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

include("grisu/float.jl")
include("grisu/fastshortest.jl")
Expand Down
4 changes: 2 additions & 2 deletions base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ library.
strftime(t) = strftime("%c", t)
strftime(fmt::AbstractString, t::Real) = strftime(fmt, TmStruct(t))
function strftime(fmt::AbstractString, tm::TmStruct)
timestr = Array{UInt8}(128)
timestr = Vector{UInt8}(128)
n = ccall(:strftime, Int, (Ptr{UInt8}, Int, Cstring, Ptr{TmStruct}),
timestr, length(timestr), fmt, &tm)
if n == 0
Expand Down Expand Up @@ -222,7 +222,7 @@ getpid() = ccall(:jl_getpid, Int32, ())
Get the local machine's host name.
"""
function gethostname()
hn = Array{UInt8}(256)
hn = Vector{UInt8}(256)
err = @static if is_windows()
ccall(:gethostname, stdcall, Int32, (Ptr{UInt8}, UInt32), hn, length(hn))
else
Expand Down
8 changes: 4 additions & 4 deletions base/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ for (fname, elty) in ((:cblas_zdotc_sub,:Complex128),
# * .. Array Arguments ..
# DOUBLE PRECISION DX(*),DY(*)
function dotc(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer)
result = Array{$elty}(1)
result = Ref{$elty}()
ccall((@blasfunc($fname), libblas), Void,
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
n, DX, incx, DY, incy, result)
result[1]
result[]
end
end
end
Expand All @@ -297,11 +297,11 @@ for (fname, elty) in ((:cblas_zdotu_sub,:Complex128),
# * .. Array Arguments ..
# DOUBLE PRECISION DX(*),DY(*)
function dotu(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer)
result = Array{$elty}(1)
result = Ref{$elty}()
ccall((@blasfunc($fname), libblas), Void,
(BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
n, DX, incx, DY, incy, result)
result[1]
result[]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion base/pcre.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ free_match_context(context) =
ccall((:pcre2_match_context_free_8, PCRE_LIB), Void, (Ptr{Void},), context)

function err_message(errno)
buffer = Array{UInt8}(256)
buffer = Vector{UInt8}(256)
ccall((:pcre2_get_error_message_8, PCRE_LIB), Void,
(Int32, Ptr{UInt8}, Csize_t), errno, buffer, sizeof(buffer))
unsafe_string(pointer(buffer))
Expand Down
2 changes: 1 addition & 1 deletion base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ end

function Base.repr(u::UUID)
u = u.value
a = Array{UInt8}(36)
a = Vector{UInt8}(36)
for i = [36:-1:25; 23:-1:20; 18:-1:15; 13:-1:10; 8:-1:1]
d = u & 0xf
a[i] = '0'+d+39*(d>9)
Expand Down
4 changes: 2 additions & 2 deletions base/socket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ function uv_getaddrinfocb(req::Ptr{Void}, status::Cint, addrinfo::Ptr{Void})
cb(IPv4(ntoh(ccall(:jl_sockaddr_host4, UInt32, (Ptr{Void},), sockaddr))))
break
#elseif ccall(:jl_sockaddr_is_ip6, Int32, (Ptr{Void},), sockaddr) == 1
# host = Array{UInt128}(1)
# host = Vector{UInt128}(1)
# scope_id = ccall(:jl_sockaddr_host6, UInt32, (Ptr{Void}, Ptr{UInt128}), sockaddr, host)
# cb(IPv6(ntoh(host[1])))
# break
Expand Down Expand Up @@ -684,7 +684,7 @@ function getipaddr()
return rv
# Uncomment to enbable IPv6
#elseif ccall(:jl_sockaddr_in_is_ip6, Int32, (Ptr{Void},), sockaddr) == 1
# host = Array{UInt128}(1)
# host = Vector{UInt128}(1)
# ccall(:jl_sockaddr_host6, UInt32, (Ptr{Void}, Ptr{UInt128}), sockaddrr, host)
# return IPv6(ntoh(host[1]))
end
Expand Down
6 changes: 3 additions & 3 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ function sprand_IJ(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloa
0 <= density <= 1 || throw(ArgumentError("$density not in [0,1]"))
N = n*m

I, J = Array{Int}(0), Array{Int}(0) # indices of nonzero elements
I, J = Vector{Int}(0), Vector{Int}(0) # indices of nonzero elements
sizehint!(I, round(Int,N*density))
sizehint!(J, round(Int,N*density))

Expand All @@ -1229,7 +1229,7 @@ function sprand_IJ(r::AbstractRNG, m::Integer, n::Integer, density::AbstractFloa
colsparsity = exp(m*L) # = 1 - coldensity
iL = 1/L

rows = Array{Int}(0)
rows = Vector{Int}(0)
for j in randsubseq(r, 1:n, coldensity)
# To get the right statistics, we *must* have a nonempty column j
# even if p*m << 1. To do this, we use an approach similar to
Expand Down Expand Up @@ -1373,7 +1373,7 @@ spzeros(m::Integer, n::Integer) = spzeros(Float64, m, n)
spzeros(Tv::Type, m::Integer, n::Integer) = spzeros(Tv, Int, m, n)
function spzeros(Tv::Type, Ti::Type, m::Integer, n::Integer)
((m < 0) || (n < 0)) && throw(ArgumentError("invalid Array dimensions"))
SparseMatrixCSC(m, n, ones(Ti, n+1), Array{Ti}(0), Array{Tv}(0))
SparseMatrixCSC(m, n, ones(Ti, n+1), Vector{Ti}(0), Vector{Tv}(0))
end
# de-splatting variant
spzeros(Tv::Type, Ti::Type, sz::Tuple{Integer,Integer}) = spzeros(Tv, Ti, sz[1], sz[2])
Expand Down
34 changes: 17 additions & 17 deletions base/sparse/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,41 +285,41 @@ for itype in UmfpackIndexTypes
return x
end
function det(lu::UmfpackLU{Float64,$itype})
mx = Array{Float64}(1)
mx = Ref{Float64}()
@isok ccall(($det_r,:libumfpack), $itype,
(Ptr{Float64},Ptr{Float64},Ptr{Void},Ptr{Float64}),
mx, C_NULL, lu.numeric, umf_info)
mx[1]
mx[]
end
function det(lu::UmfpackLU{Complex128,$itype})
mx = Array{Float64}(1)
mz = Array{Float64}(1)
mx = Ref{Float64}()
mz = Ref{Float64}()
@isok ccall(($det_z,:libumfpack), $itype,
(Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Void},Ptr{Float64}),
mx, mz, C_NULL, lu.numeric, umf_info)
complex(mx[1], mz[1])
complex(mx[], mz[])
end
function umf_lunz(lu::UmfpackLU{Float64,$itype})
lnz = Array{$itype}(1)
unz = Array{$itype}(1)
n_row = Array{$itype}(1)
n_col = Array{$itype}(1)
nz_diag = Array{$itype}(1)
lnz = Ref{$itype}()
unz = Ref{$itype}()
n_row = Ref{$itype}()
n_col = Ref{$itype}()
nz_diag = Ref{$itype}()
@isok ccall(($lunz_r,:libumfpack), $itype,
(Ptr{$itype},Ptr{$itype},Ptr{$itype},Ptr{$itype},Ptr{$itype},Ptr{Void}),
lnz, unz, n_row, n_col, nz_diag, lu.numeric)
(lnz[1], unz[1], n_row[1], n_col[1], nz_diag[1])
(lnz[], unz[], n_row[], n_col[], nz_diag[])
end
function umf_lunz(lu::UmfpackLU{Complex128,$itype})
lnz = Array{$itype}(1)
unz = Array{$itype}(1)
n_row = Array{$itype}(1)
n_col = Array{$itype}(1)
nz_diag = Array{$itype}(1)
lnz = Ref{$itype}()
unz = Ref{$itype}()
n_row = Ref{$itype}()
n_col = Ref{$itype}()
nz_diag = Ref{$itype}()
@isok ccall(($lunz_z,:libumfpack), $itype,
(Ptr{$itype},Ptr{$itype},Ptr{$itype},Ptr{$itype},Ptr{$itype},Ptr{Void}),
lnz, unz, n_row, n_col, nz_diag, lu.numeric)
(lnz[1], unz[1], n_row[1], n_col[1], nz_diag[1])
(lnz[], unz[], n_row[], n_col[], nz_diag[])
end
function umf_extract(lu::UmfpackLU{Float64,$itype})
umfpack_numeric!(lu) # ensure the numeric decomposition exists
Expand Down
8 changes: 4 additions & 4 deletions base/special/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Compute the gamma function of `x`.
gamma(x::Real) = gamma(float(x))

function lgamma_r(x::Float64)
signp = Array{Int32}(1)
signp = Ref{Int32}()
y = ccall((:lgamma_r,libm), Float64, (Float64, Ptr{Int32}), x, signp)
return y, signp[1]
return y, signp[]
end
function lgamma_r(x::Float32)
signp = Array{Int32}(1)
signp = Ref{Int32}()
y = ccall((:lgammaf_r,libm), Float32, (Float32, Ptr{Int32}), x, signp)
return y, signp[1]
return y, signp[]
end
lgamma_r(x::Real) = lgamma_r(float(x))
lgamma_r(x::Number) = lgamma(x), 1 # lgamma does not take abs for non-real x
Expand Down
16 changes: 8 additions & 8 deletions base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,25 @@ function cpu_summary(io::IO=STDOUT, cpu::Array{CPUinfo}=cpu_info())
end

function cpu_info()
UVcpus = Array{Ptr{UV_cpu_info_t}}(1)
count = Array{Int32}(1)
UVcpus = Ref{Ptr{UV_cpu_info_t}}()
count = Ref{Int32}()
Base.uv_error("uv_cpu_info",ccall(:uv_cpu_info, Int32, (Ptr{Ptr{UV_cpu_info_t}}, Ptr{Int32}), UVcpus, count))
cpus = Array{CPUinfo}(count[1])
cpus = Vector{CPUinfo}(count[])
for i = 1:length(cpus)
cpus[i] = CPUinfo(unsafe_load(UVcpus[1], i))
cpus[i] = CPUinfo(unsafe_load(UVcpus[], i))
end
ccall(:uv_free_cpu_info, Void, (Ptr{UV_cpu_info_t}, Int32), UVcpus[1], count[1])
ccall(:uv_free_cpu_info, Void, (Ptr{UV_cpu_info_t}, Int32), UVcpus[], count[])
return cpus
end

function uptime()
uptime_ = Array{Float64}(1)
uptime_ = Ref{Float64}()
Base.uv_error("uv_uptime",ccall(:uv_uptime, Int32, (Ptr{Float64},), uptime_))
return uptime_[1]
return uptime_[]
end

function loadavg()
loadavg_ = Array{Float64}(3)
loadavg_ = Vector{Float64}(3)
ccall(:uv_loadavg, Void, (Ptr{Float64},), loadavg_)
return loadavg_
end
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ if is_windows()
function getpass(prompt::AbstractString)
print(prompt)
flush(STDOUT)
p = Array{UInt8}(128) # mimic Unix getpass in ignoring more than 128-char passwords
p = Vector{UInt8}(128) # mimic Unix getpass in ignoring more than 128-char passwords
# (also avoids any potential memory copies arising from push!)
try
plen = 0
Expand Down

0 comments on commit aa74426

Please sign in to comment.