Skip to content

Commit c3513ca

Browse files
committed
rewrite zeros(T, dims) to fill(zero(T), dims)
1 parent e07898e commit c3513ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+130
-130
lines changed

base/env.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if Sys.iswindows()
1313
if len == 0
1414
return Libc.GetLastError() != ERROR_ENVVAR_NOT_FOUND ? "" : onError(str)
1515
end
16-
val = zeros(UInt16,len)
16+
val = fill(zero(UInt16), len)
1717
ret = ccall(:GetEnvironmentVariableW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32),var,val,len)
1818
if (ret == 0 && len != 1) || ret != len-1 || val[end] != 0
1919
error(string("getenv: ", str, ' ', len, "-1 != ", ret, ": ", Libc.FormatMessage()))

base/linalg/bidiag.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ end
135135
#Converting from Bidiagonal to dense Matrix
136136
function Matrix{T}(A::Bidiagonal) where T
137137
n = size(A, 1)
138-
B = zeros(T, n, n)
138+
B = fill(zero(T), n, n)
139139
for i = 1:n - 1
140140
B[i,i] = A.dv[i]
141141
if A.uplo == 'U'
@@ -605,7 +605,7 @@ function eigvecs(M::Bidiagonal{T}) where T
605605
n = length(M.dv)
606606
Q = Matrix{T}(uninitialized, n,n)
607607
blks = [0; find(x -> x == 0, M.ev); n]
608-
v = zeros(T, n)
608+
v = fill(zero(T), n)
609609
if M.uplo == 'U'
610610
for idx_block = 1:length(blks) - 1, i = blks[idx_block] + 1:blks[idx_block + 1] #index of eigenvector
611611
fill!(v, zero(T))

base/linalg/bitarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ end
2323
#if mA == 0; return C; end
2424
#col_ch = num_bit_chunks(mA)
2525
## TODO: avoid using aux chunks and copy (?)
26-
#aux_chunksA = zeros(UInt64, col_ch)
27-
#aux_chunksB = [zeros(UInt64, col_ch) for j=1:nB]
26+
#aux_chunksA = fill(zero(UInt64), col_ch)
27+
#aux_chunksB = [fill(zero(UInt64), col_ch) for j=1:nB]
2828
#for j = 1:nB
2929
#Base.copy_chunks!(aux_chunksB[j], 1, B.chunks, (j-1)*mA+1, mA)
3030
#end

base/linalg/cholesky.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function getproperty(C::CholeskyPivoted{T}, d::Symbol) where T<:BlasFloat
404404
return getfield(C, :piv)
405405
elseif d == :P
406406
n = size(C, 1)
407-
P = zeros(T, n, n)
407+
P = fill(zero(T), n, n)
408408
for i = 1:n
409409
P[getfield(C, :piv)[i], i] = one(T)
410410
end

base/linalg/dense.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ end
335335
function diagm_container(kv::Pair{<:Integer,<:AbstractVector}...)
336336
T = promote_type(map(x -> eltype(x.second), kv)...)
337337
n = mapreduce(x -> length(x.second) + abs(x.first), max, kv)
338-
return zeros(T, n, n)
338+
return fill(zero(T), n, n)
339339
end
340340
function diagm_container(kv::Pair{<:Integer,<:BitVector}...)
341341
n = mapreduce(x -> length(x.second) + abs(x.first), max, kv)
@@ -1280,7 +1280,7 @@ function pinv(A::StridedMatrix{T}, tol::Real) where T
12801280
if istril(A)
12811281
if istriu(A)
12821282
maxabsA = maximum(abs.(diag(A)))
1283-
B = zeros(Tout, n, m)
1283+
B = fill(zero(Tout), n, m)
12841284
for i = 1:min(m, n)
12851285
if abs(A[i,i]) > tol*maxabsA
12861286
Aii = inv(A[i,i])
@@ -1294,7 +1294,7 @@ function pinv(A::StridedMatrix{T}, tol::Real) where T
12941294
end
12951295
SVD = svdfact(A, full = false)
12961296
Stype = eltype(SVD.S)
1297-
Sinv = zeros(Stype, length(SVD.S))
1297+
Sinv = fill(zero(Stype), length(SVD.S))
12981298
index = SVD.S .> tol*maximum(SVD.S)
12991299
Sinv[index] = one(Stype) ./ SVD.S[index]
13001300
Sinv[find(.!isfinite.(Sinv))] = zero(Stype)

base/linalg/diagonal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ end
8282
r
8383
end
8484
diagzero(::Diagonal{T},i,j) where {T} = zero(T)
85-
diagzero(D::Diagonal{Matrix{T}},i,j) where {T} = zeros(T, size(D.diag[i], 1), size(D.diag[j], 2))
85+
diagzero(D::Diagonal{Matrix{T}},i,j) where {T} = fill(zero(T), size(D.diag[i], 1), size(D.diag[j], 2))
8686

8787
function setindex!(D::Diagonal, v, i::Int, j::Int)
8888
@boundscheck checkbounds(D, i, j)

base/linalg/hessenberg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ function getproperty(F::Hessenberg, d::Symbol)
6767
end
6868

6969
function getindex(A::HessenbergQ, i::Integer, j::Integer)
70-
x = zeros(eltype(A), size(A, 1))
70+
x = fill(zero(eltype(A)), size(A, 1))
7171
x[i] = 1
72-
y = zeros(eltype(A), size(A, 2))
72+
y = fill(zero(eltype(A)), size(A, 2))
7373
y[j] = 1
7474
return dot(x, mul!(A, y))
7575
end

base/linalg/lapack.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ and `tau`, which stores the elementary reflectors.
736736
"""
737737
function geqp3!(A::AbstractMatrix{<:BlasFloat})
738738
m, n = size(A)
739-
geqp3!(A, zeros(BlasInt, n), similar(A, min(m, n)))
739+
geqp3!(A, fill(zero(BlasInt), n), similar(A, min(m, n)))
740740
end
741741

742742
## Complete orthogonaliztion tools
@@ -1206,7 +1206,7 @@ for (gelsd, gelsy, elty) in
12061206
if size(B, 1) != m
12071207
throw(DimensionMismatch("B has leading dimension $(size(B,1)) but needs $m"))
12081208
end
1209-
newB = [B; zeros($elty, max(0, n - size(B, 1)), size(B, 2))]
1209+
newB = [B; fill(zero($elty), max(0, n - size(B, 1)), size(B, 2))]
12101210
s = similar(A, $elty, min(m, n))
12111211
rnk = Ref{BlasInt}()
12121212
info = Ref{BlasInt}()
@@ -1250,10 +1250,10 @@ for (gelsd, gelsy, elty) in
12501250
if size(B, 1) != m
12511251
throw(DimensionMismatch("B has leading dimension $(size(B,1)) but needs $m"))
12521252
end
1253-
newB = [B; zeros($elty, max(0, n - size(B, 1)), size(B, 2))]
1253+
newB = [B; fill(zero($elty), max(0, n - size(B, 1)), size(B, 2))]
12541254
lda = max(1, stride(A,2))
12551255
ldb = max(1, stride(newB,2))
1256-
jpvt = zeros(BlasInt, n)
1256+
jpvt = fill(zero(BlasInt), n)
12571257
rnk = Ref{BlasInt}()
12581258
work = Vector{$elty}(uninitialized, 1)
12591259
lwork = BlasInt(-1)
@@ -1299,7 +1299,7 @@ for (gelsd, gelsy, elty, relty) in
12991299
if size(B, 1) != m
13001300
throw(DimensionMismatch("B has leading dimension $(size(B,1)) but needs $m"))
13011301
end
1302-
newB = [B; zeros($elty, max(0, n - size(B, 1)), size(B, 2))]
1302+
newB = [B; fill(zero($elty), max(0, n - size(B, 1)), size(B, 2))]
13031303
s = similar(A, $relty, min(m, n))
13041304
rnk = Ref{BlasInt}()
13051305
info = Ref{BlasInt}()
@@ -1345,10 +1345,10 @@ for (gelsd, gelsy, elty, relty) in
13451345
if size(B, 1) != m
13461346
throw(DimensionMismatch("B has leading dimension $(size(B,1)) but needs $m"))
13471347
end
1348-
newB = [B; zeros($elty, max(0, n - size(B, 1)), size(B, 2))]
1348+
newB = [B; fill(zero($elty), max(0, n - size(B, 1)), size(B, 2))]
13491349
lda = max(1, m)
13501350
ldb = max(1, m, n)
1351-
jpvt = zeros(BlasInt, n)
1351+
jpvt = fill(zero(BlasInt), n)
13521352
rnk = Ref{BlasInt}(1)
13531353
work = Vector{$elty}(uninitialized, 1)
13541354
lwork = BlasInt(-1)
@@ -1424,7 +1424,7 @@ for (gglse, elty) in ((:dgglse_, :Float64),
14241424
if length(d) != p
14251425
throw(DimensionMismatch("d has length $(length(d)), needs $p"))
14261426
end
1427-
X = zeros($elty, n)
1427+
X = fill(zero($elty), n)
14281428
info = Ref{BlasInt}()
14291429
work = Vector{$elty}(uninitialized, 1)
14301430
lwork = BlasInt(-1)
@@ -3721,7 +3721,7 @@ for (stev, stebz, stegr, stein, elty) in
37213721
if length(ev_in) != n - 1
37223722
throw(DimensionMismatch("ev_in has length $(length(ev_in)) but needs one less than dv's length, $n)"))
37233723
end
3724-
ev = [ev_in; zeros($elty,1)]
3724+
ev = [ev_in; fill(zero($elty),1)]
37253725
ldz = n #Leading dimension
37263726
#Number of eigenvalues to find
37273727
if !(1 <= length(w_in) <= n)

base/linalg/lq.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function getproperty(F::LQ, d::Symbol)
8686
end
8787

8888
getindex(A::LQPackedQ, i::Integer, j::Integer) =
89-
mul!(A, setindex!(zeros(eltype(A), size(A, 2)), 1, j))[i]
89+
mul!(A, setindex!(fill(zero(eltype(A)), size(A, 2)), 1, j))[i]
9090

9191
function show(io::IO, C::LQ)
9292
println(io, "$(typeof(C)) with factors L and Q:")
@@ -160,7 +160,7 @@ function *(adjA::Adjoint{<:Any,<:LQPackedQ}, B::StridedVecOrMat)
160160
if size(B,1) == size(A.factors,2)
161161
mul!(adjoint(AbstractMatrix{TAB}(A)), copy_oftype(B, TAB))
162162
elseif size(B,1) == size(A.factors,1)
163-
mul!(adjoint(AbstractMatrix{TAB}(A)), [B; zeros(TAB, size(A.factors, 2) - size(A.factors, 1), size(B, 2))])
163+
mul!(adjoint(AbstractMatrix{TAB}(A)), [B; fill(zero(TAB), size(A.factors, 2) - size(A.factors, 1), size(B, 2))])
164164
else
165165
throw(DimensionMismatch("first dimension of B, $(size(B,1)), must equal one of the dimensions of A, $(size(A))"))
166166
end
@@ -235,7 +235,7 @@ function *(A::StridedVecOrMat, Q::LQPackedQ)
235235
if size(A, 2) == size(Q.factors, 2)
236236
C = copy_oftype(A, TR)
237237
elseif size(A, 2) == size(Q.factors, 1)
238-
C = zeros(TR, size(A, 1), size(Q.factors, 2))
238+
C = fill(zero(TR), size(A, 1), size(Q.factors, 2))
239239
copyto!(C, 1, A, 1, length(A))
240240
else
241241
_rightappdimmismatch("columns")
@@ -248,7 +248,7 @@ function *(adjA::Adjoint{<:Any,<:StridedMatrix}, Q::LQPackedQ)
248248
if size(A, 1) == size(Q.factors, 2)
249249
C = adjoint!(similar(A, TR, reverse(size(A))), A)
250250
elseif size(A, 1) == size(Q.factors, 1)
251-
C = zeros(TR, size(A, 2), size(Q.factors, 2))
251+
C = fill(zero(TR), size(A, 2), size(Q.factors, 2))
252252
adjoint!(view(C, :, 1:size(A, 1)), A)
253253
else
254254
_rightappdimmismatch("rows")

base/linalg/qr.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ QRPivoted(factors::AbstractMatrix{T}, τ::Vector{T}, jpvt::Vector{BlasInt}) wher
135135

136136
function qrfactUnblocked!(A::AbstractMatrix{T}) where {T}
137137
m, n = size(A)
138-
τ = zeros(T, min(m,n))
138+
τ = fill(zero(T), min(m,n))
139139
for k = 1:min(m - 1 + !(T<:Real), n)
140140
x = view(A, k:m, k)
141141
τk = reflector!(x)
@@ -460,7 +460,7 @@ function getproperty(F::QRPivoted{T}, d::Symbol) where T
460460
elseif d == :P
461461
p = F.p
462462
n = length(p)
463-
P = zeros(T, n, n)
463+
P = fill(zero(T), n, n)
464464
for i in 1:n
465465
P[p[i],i] = one(T)
466466
end
@@ -514,9 +514,9 @@ size(A::AbstractQ) = size(A, 1), size(A, 2)
514514

515515

516516
function getindex(A::AbstractQ, i::Integer, j::Integer)
517-
x = zeros(eltype(A), size(A, 1))
517+
x = fill(zero(eltype(A)), size(A, 1))
518518
x[i] = 1
519-
y = zeros(eltype(A), size(A, 2))
519+
y = fill(zero(eltype(A)), size(A, 2))
520520
y[j] = 1
521521
return dot(x, mul!(A, y))
522522
end
@@ -558,7 +558,7 @@ function (*)(A::AbstractQ, b::StridedVector)
558558
if size(A.factors, 1) == length(b)
559559
bnew = copy_oftype(b, TAb)
560560
elseif size(A.factors, 2) == length(b)
561-
bnew = [b; zeros(TAb, size(A.factors, 1) - length(b))]
561+
bnew = [b; fill(zero(TAb), size(A.factors, 1) - length(b))]
562562
else
563563
throw(DimensionMismatch("vector must have length either $(size(A.factors, 1)) or $(size(A.factors, 2))"))
564564
end
@@ -570,7 +570,7 @@ function (*)(A::AbstractQ, B::StridedMatrix)
570570
if size(A.factors, 1) == size(B, 1)
571571
Bnew = copy_oftype(B, TAB)
572572
elseif size(A.factors, 2) == size(B, 1)
573-
Bnew = [B; zeros(TAB, size(A.factors, 1) - size(B,1), size(B, 2))]
573+
Bnew = [B; fill(zero(TAB), size(A.factors, 1) - size(B,1), size(B, 2))]
574574
else
575575
throw(DimensionMismatch("first dimension of matrix must have size either $(size(A.factors, 1)) or $(size(A.factors, 2))"))
576576
end
@@ -711,7 +711,7 @@ function *(A::StridedMatrix, adjB::Adjoint{<:Any,<:AbstractQ})
711711
copyto!(AA, A)
712712
return mul!(AA, adjoint(BB))
713713
elseif size(A,2) == size(B.factors,2)
714-
return mul!([A zeros(TAB, size(A, 1), size(B.factors, 1) - size(B.factors, 2))], adjoint(BB))
714+
return mul!([A fill(zero(TAB), size(A, 1), size(B.factors, 1) - size(B.factors, 2))], adjoint(BB))
715715
else
716716
throw(DimensionMismatch("matrix A has dimensions $(size(A)) but matrix B has dimensions $(size(B))"))
717717
end
@@ -788,7 +788,7 @@ function ldiv!(A::QR{T}, B::StridedMatrix{T}) where T
788788
R = A.R
789789
@inbounds begin
790790
if n > m # minimum norm solution
791-
τ = zeros(T,m)
791+
τ = fill(zero(T),m)
792792
for k = m:-1:1 # Trapezoid to triangular by elementary operation
793793
x = view(R, k, [k; m + 1:n])
794794
τk = reflector!(x)
@@ -845,8 +845,8 @@ _cut_B(x::AbstractVector, r::UnitRange) = length(x) > length(r) ? x[r] : x
845845
_cut_B(X::AbstractMatrix, r::UnitRange) = size(X, 1) > length(r) ? X[r,:] : X
846846

847847
## append right hand side with zeros if necessary
848-
_zeros(::Type{T}, b::AbstractVector, n::Integer) where {T} = zeros(T, max(length(b), n))
849-
_zeros(::Type{T}, B::AbstractMatrix, n::Integer) where {T} = zeros(T, max(size(B, 1), n), size(B, 2))
848+
_zeros(::Type{T}, b::AbstractVector, n::Integer) where {T} = fill(zero(T), max(length(b), n))
849+
_zeros(::Type{T}, B::AbstractMatrix, n::Integer) where {T} = fill(zero(T), max(size(B, 1), n), size(B, 2))
850850

851851
function (\)(A::Union{QR{TA},QRCompactWY{TA},QRPivoted{TA}}, B::AbstractVecOrMat{TB}) where {TA,TB}
852852
S = promote_type(TA,TB)

base/linalg/svd.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,23 +439,23 @@ svd(x::Number, y::Number) = first.(svd(fill(x, 1, 1), fill(y, 1, 1)))
439439
elseif d == :D1
440440
m = size(FU, 1)
441441
if m - Fk - Fl >= 0
442-
return [Matrix{T}(I, Fk, Fk) zeros(T, Fk, Fl) ;
443-
zeros(T, Fl, Fk) Diagonal(Fa[Fk + 1:Fk + Fl]);
444-
zeros(T, m - Fk - Fl, Fk + Fl) ]
442+
return [Matrix{T}(I, Fk, Fk) fill(zero(T), Fk, Fl) ;
443+
fill(zero(T), Fl, Fk) Diagonal(Fa[Fk + 1:Fk + Fl]);
444+
fill(zero(T), m - Fk - Fl, Fk + Fl) ]
445445
else
446-
return [Matrix{T}(I, m, Fk) [zeros(T, Fk, m - Fk); Diagonal(Fa[Fk + 1:m])] zeros(T, m, Fk + Fl - m)]
446+
return [Matrix{T}(I, m, Fk) [fill(zero(T), Fk, m - Fk); Diagonal(Fa[Fk + 1:m])] fill(zero(T), m, Fk + Fl - m)]
447447
end
448448
elseif d == :D2
449449
m = size(FU, 1)
450450
p = size(FV, 1)
451451
if m - Fk - Fl >= 0
452-
return [zeros(T, Fl, Fk) Diagonal(Fb[Fk + 1:Fk + Fl]); zeros(T, p - Fl, Fk + Fl)]
452+
return [fill(zero(T), Fl, Fk) Diagonal(Fb[Fk + 1:Fk + Fl]); fill(zero(T), p - Fl, Fk + Fl)]
453453
else
454-
return [zeros(T, p, Fk) [Diagonal(Fb[Fk + 1:m]); zeros(T, Fk + p - m, m - Fk)] [zeros(T, m - Fk, Fk + Fl - m); Matrix{T}(I, Fk + p - m, Fk + Fl - m)]]
454+
return [fill(zero(T), p, Fk) [Diagonal(Fb[Fk + 1:m]); fill(zero(T), Fk + p - m, m - Fk)] [fill(zero(T), m - Fk, Fk + Fl - m); Matrix{T}(I, Fk + p - m, Fk + Fl - m)]]
455455
end
456456
elseif d == :R0
457457
n = size(FQ, 1)
458-
return [zeros(T, Fk + Fl, n - Fk - Fl) FR]
458+
return [fill(zero(T), Fk + Fl, n - Fk - Fl) FR]
459459
else
460460
getfield(F, d)
461461
end

base/linalg/triangular.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,7 @@ function log(A0::UpperTriangular{T}) where T<:BlasFloat
20932093
end
20942094

20952095
# Compute the Padé approximation
2096-
Y = zeros(T, n, n)
2096+
Y = fill(zero(T), n, n)
20972097
for k = 1:m
20982098
Y = Y + w[k] * (A / (x[k] * A + I))
20992099
end
@@ -2297,7 +2297,7 @@ function sqrt(A::UpperTriangular{T},::Val{realmatrix}) where {T,realmatrix}
22972297
B = A.data
22982298
n = checksquare(B)
22992299
t = realmatrix ? typeof(sqrt(zero(T))) : typeof(sqrt(complex(zero(T))))
2300-
R = zeros(t, n, n)
2300+
R = fill(zero(t), n, n)
23012301
tt = typeof(zero(t)*zero(t))
23022302
@inbounds for j = 1:n
23032303
R[j,j] = realmatrix ? sqrt(B[j,j]) : sqrt(complex(B[j,j]))

base/linalg/tridiag.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ AbstractMatrix{T}(S::SymTridiagonal) where {T} =
8282
SymTridiagonal(convert(AbstractVector{T}, S.dv), convert(AbstractVector{T}, S.ev))
8383
function Matrix{T}(M::SymTridiagonal) where T
8484
n = size(M, 1)
85-
Mf = zeros(T, n, n)
85+
Mf = fill(zero(T), n, n)
8686
@inbounds begin
8787
@simd for i = 1:n-1
8888
Mf[i,i] = M.dv[i]

base/linalg/uniformscaling.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ chol(J::UniformScaling, args...) = ((C, info) = _chol!(J, nothing); @assertposde
378378

379379

380380
## Matrix construction from UniformScaling
381-
Matrix{T}(s::UniformScaling, dims::Dims{2}) where {T} = setindex!(zeros(T, dims), T(s.λ), diagind(dims...))
381+
Matrix{T}(s::UniformScaling, dims::Dims{2}) where {T} = setindex!(fill(zero(T), dims), T(s.λ), diagind(dims...))
382382
Matrix{T}(s::UniformScaling, m::Integer, n::Integer) where {T} = Matrix{T}(s, Dims((m, n)))
383383
Matrix(s::UniformScaling, m::Integer, n::Integer) = Matrix(s, Dims((m, n)))
384384
Matrix(s::UniformScaling, dims::Dims{2}) = Matrix{eltype(s)}(s, dims)

base/multidimensional.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ julia> unique(A, 3)
17351735
```
17361736
"""
17371737
@generated function unique(A::AbstractArray{T,N}, dim::Int) where {T,N}
1738-
inds = inds -> zeros(UInt, inds)
1738+
inds = inds -> fill(zero(UInt), inds)
17391739
quote
17401740
1 <= dim <= $N || return copy(A)
17411741
hashes = similar($inds, axes(A, dim))

base/path.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ abspath(a::AbstractString, b::AbstractString...) = abspath(joinpath(a,b...))
288288
if Sys.iswindows()
289289
function realpath(path::AbstractString)
290290
p = cwstring(path)
291-
buf = zeros(UInt16, length(p))
291+
buf = fill(zero(UInt16), length(p))
292292
while true
293293
n = ccall((:GetFullPathNameW, "kernel32"), stdcall,
294294
UInt32, (Ptr{UInt16}, UInt32, Ptr{UInt16}, Ptr{Cvoid}),
@@ -302,7 +302,7 @@ end
302302

303303
function longpath(path::AbstractString)
304304
p = cwstring(path)
305-
buf = zeros(UInt16, length(p))
305+
buf = fill(zero(UInt16), length(p))
306306
while true
307307
n = ccall((:GetLongPathNameW, "kernel32"), stdcall,
308308
UInt32, (Ptr{UInt16}, Ptr{UInt16}, UInt32),

base/pkg/resolve/maxsum.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ mutable struct Messages
229229

230230
# initialize cavity messages to 0
231231
gadj = graph.gadj
232-
msg = [[zeros(FieldValue, spp[p0]) for p1 = 1:length(gadj[p0])] for p0 = 1:np]
232+
msg = [[fill(zero(FieldValue), spp[p0]) for p1 = 1:length(gadj[p0])] for p0 = 1:np]
233233

234234
return new(msg, fld, initial_fld, falses(np), np)
235235
end

base/random/dSFMT.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const JN32 = (N+1)*4+1+1
2727
mutable struct DSFMT_state
2828
val::Vector{Int32}
2929

30-
function DSFMT_state(val::Vector{Int32} = zeros(Int32, JN32))
30+
function DSFMT_state(val::Vector{Int32} = fill(zero(Int32), JN32))
3131
length(val) == JN32 ||
3232
throw(DomainError(length(val), "Expected length: $JN32."))
3333
new(val)
@@ -188,7 +188,7 @@ function dsfmt_jump(s::DSFMT_state, jp::GF2X)
188188
val = s.val
189189
nval = length(val)
190190
index = val[nval - 1]
191-
work = zeros(Int32, JN32)
191+
work = fill(zero(Int32), JN32)
192192
rwork = reinterpret(UInt64, work)
193193
dsfmt = Vector{UInt64}(uninitialized, nval >> 1)
194194
ccall(:memcpy, Ptr{Cvoid}, (Ptr{UInt64}, Ptr{Int32}, Csize_t),

0 commit comments

Comments
 (0)