Skip to content

Commit cbf449d

Browse files
committed
Replace some uses of Array by Vector or Matrix
1 parent 044ff21 commit cbf449d

File tree

13 files changed

+164
-164
lines changed

13 files changed

+164
-164
lines changed

Compiler/src/typeutils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ has_extended_info(@nospecialize x) = (!isa(x, Type) && !isvarargtype(x)) || isTy
4848
# certain combinations of `a` and `b` where one/both isa/are `Union`/`UnionAll` type(s)s.
4949
isnotbrokensubtype(@nospecialize(a), @nospecialize(b)) = (!iskindtype(b) || !isType(a) || hasuniquerep(a.parameters[1]) || b <: a)
5050

51-
function argtypes_to_type(argtypes::Array{Any,1})
51+
function argtypes_to_type(argtypes::Vector{Any})
5252
argtypes = anymap(@nospecialize(a) -> isvarargtype(a) ? a : widenconst(a), argtypes)
5353
filter!(@nospecialize(x) -> !isvarargtype(x) || valid_as_lattice(unwrapva(x), true), argtypes)
5454
all(@nospecialize(x) -> isvarargtype(x) || valid_as_lattice(x, true), argtypes) || return Bottom

Compiler/src/utilities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function contains_is(itr, @nospecialize(x))
2121
return false
2222
end
2323

24-
anymap(f::Function, a::Array{Any,1}) = Any[ f(a[i]) for i in 1:length(a) ]
24+
anymap(f::Function, a::Vector{Any}) = Any[ f(a[i]) for i in 1:length(a) ]
2525

2626
############
2727
# inlining #

Compiler/test/inference.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ end
105105

106106
# issue #51694
107107
@test Compiler.type_more_complex(
108-
Base.Generator{Base.Iterators.Flatten{Array{Bool, 1}}, typeof(identity)},
109-
Base.Generator{Array{Bool, 1}, typeof(identity)},
108+
Base.Generator{Base.Iterators.Flatten{Vector{Bool}}, typeof(identity)},
109+
Base.Generator{Vector{Bool}, typeof(identity)},
110110
Core.svec(), 0, 0, 0)
111111
@test Compiler.type_more_complex(
112-
Base.Generator{Base.Iterators.Flatten{Base.Generator{Array{Bool, 1}, typeof(identity)}}, typeof(identity)},
113-
Base.Generator{Array{Bool, 1}, typeof(identity)},
112+
Base.Generator{Base.Iterators.Flatten{Base.Generator{Vector{Bool}, typeof(identity)}}, typeof(identity)},
113+
Base.Generator{Vector{Bool}, typeof(identity)},
114114
Core.svec(), 0, 0, 0)
115115

116116
let # 40336
@@ -419,7 +419,7 @@ end
419419

420420
# issue #12826
421421
f12826(v::Vector{I}) where {I<:Integer} = v[1]
422-
@test Base.return_types(f12826,Tuple{Array{I,1} where I<:Integer})[1] == Integer
422+
@test Base.return_types(f12826,Tuple{Vector{I} where I<:Integer})[1] == Integer
423423

424424

425425
# non-terminating inference, issue #14009
@@ -1465,8 +1465,8 @@ let egal_tfunc
14651465
@test egal_tfunc(Array, Array) == Bool
14661466
@test egal_tfunc(Array, AbstractArray{Int}) == Bool
14671467
@test egal_tfunc(Array{Real}, AbstractArray{Int}) === Const(false)
1468-
@test egal_tfunc(Array{Real, 2}, AbstractArray{Real, 2}) === Bool
1469-
@test egal_tfunc(Array{Real, 2}, AbstractArray{Int, 2}) === Const(false)
1468+
@test egal_tfunc(Matrix{Real}, AbstractMatrix{Real}) === Bool
1469+
@test egal_tfunc(Matrix{Real}, AbstractMatrix{Int}) === Const(false)
14701470
@test egal_tfunc(DataType, Int) === Const(false)
14711471
@test egal_tfunc(DataType, Const(Int)) === Bool
14721472
@test egal_tfunc(DataType, Const(Array)) === Const(false)

base/array.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,10 @@ end
399399

400400
## Constructors ##
401401

402-
similar(a::Array{T,1}) where {T} = Vector{T}(undef, size(a,1))
403-
similar(a::Array{T,2}) where {T} = Matrix{T}(undef, size(a,1), size(a,2))
404-
similar(a::Array{T,1}, S::Type) where {T} = Vector{S}(undef, size(a,1))
405-
similar(a::Array{T,2}, S::Type) where {T} = Matrix{S}(undef, size(a,1), size(a,2))
402+
similar(a::Vector{T}) where {T} = Vector{T}(undef, size(a,1))
403+
similar(a::Matrix{T}) where {T} = Matrix{T}(undef, size(a,1), size(a,2))
404+
similar(a::Vector{T}, S::Type) where {T} = Vector{S}(undef, size(a,1))
405+
similar(a::Matrix{T}, S::Type) where {T} = Matrix{S}(undef, size(a,1), size(a,2))
406406
similar(a::Array{T}, m::Int) where {T} = Vector{T}(undef, m)
407407
similar(a::Array, T::Type, dims::Dims{N}) where {N} = Array{T,N}(undef, dims)
408408
similar(a::Array{T}, dims::Dims{N}) where {T,N} = Array{T,N}(undef, dims)
@@ -1832,12 +1832,12 @@ julia> insert!(Any[1:6;], 3, "here")
18321832
6
18331833
```
18341834
"""
1835-
function insert!(a::Array{T,1}, i::Integer, item) where T
1835+
function insert!(a::Vector{T}, i::Integer, item) where T
18361836
@_propagate_inbounds_meta
18371837
item = item isa T ? item : convert(T, item)::T
18381838
return _insert!(a, i, item)
18391839
end
1840-
function _insert!(a::Array{T,1}, i::Integer, item::T) where T
1840+
function _insert!(a::Vector{T}, i::Integer, item::T) where T
18411841
@_noub_meta
18421842
# Throw convert error before changing the shape of the array
18431843
_growat!(a, i, 1)

base/iostream.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Mostly used to represent files returned by [`open`](@ref).
1212
"""
1313
mutable struct IOStream <: IO
1414
handle::Ptr{Cvoid}
15-
ios::Array{UInt8,1}
15+
ios::Vector{UInt8}
1616
name::String
1717
mark::Int64
1818
lock::ReentrantLock
1919
_dolock::Bool
2020

21-
IOStream(name::AbstractString, buf::Array{UInt8,1}) = new(pointer(buf), buf, name, -1, ReentrantLock(), true)
21+
IOStream(name::AbstractString, buf::Vector{UInt8}) = new(pointer(buf), buf, name, -1, ReentrantLock(), true)
2222
end
2323

2424
function IOStream(name::AbstractString, finalize::Bool)
@@ -470,7 +470,7 @@ take!(s::IOStream) =
470470
@_lock_ios s ccall(:jl_take_buffer, Vector{UInt8}, (Ptr{Cvoid},), s.ios)
471471

472472
function readuntil(s::IOStream, delim::UInt8; keep::Bool=false)
473-
@_lock_ios s ccall(:jl_readuntil, Array{UInt8,1}, (Ptr{Cvoid}, UInt8, UInt8, UInt8), s.ios, delim, 0, !keep)
473+
@_lock_ios s ccall(:jl_readuntil, Vector{UInt8}, (Ptr{Cvoid}, UInt8, UInt8, UInt8), s.ios, delim, 0, !keep)
474474
end
475475

476476
# like readuntil, above, but returns a String without requiring a copy

base/libdl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ if (Sys.islinux() || Sys.isbsd()) && !Sys.isapple()
279279

280280
# This callback function called by dl_iterate_phdr() on Linux and BSD's
281281
# DL_ITERATE_PHDR(3) on freebsd
282-
function dl_phdr_info_callback(di::dl_phdr_info, size::Csize_t, dynamic_libraries::Array{String,1})
282+
function dl_phdr_info_callback(di::dl_phdr_info, size::Csize_t, dynamic_libraries::Vector{String})
283283
name = unsafe_string(di.name)
284284
push!(dynamic_libraries, name)
285285
return Cint(0)

doc/src/manual/interfaces.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ library module, only supports two dimensions, so it just defines
255255
`getindex(A::SparseMatrixCSC, i::Int, j::Int)`. The same holds for [`setindex!`](@ref).
256256

257257
Returning to the sequence of squares from above, we could instead define it as a subtype of an
258-
`AbstractArray{Int, 1}`:
258+
`AbstractVector{Int}`:
259259

260260
```jldoctest squarevectype
261-
julia> struct SquaresVector <: AbstractArray{Int, 1}
261+
julia> struct SquaresVector <: AbstractVector{Int}
262262
count::Int
263263
end
264264

doc/src/manual/performance-tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ of type `Array{Any}`). But, if you're using one of these structures and happen t
541541
of an element, it helps to share this knowledge with the compiler:
542542

543543
```julia
544-
function foo(a::Array{Any,1})
544+
function foo(a::Vector{Any})
545545
x = a[1]::Int32
546546
b = x+1
547547
...

test/core.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,12 @@ end
462462
mutable struct A3890{T1}
463463
x::Matrix{Complex{T1}}
464464
end
465-
@test A3890{Float64}.types[1] === Array{ComplexF64,2}
465+
@test A3890{Float64}.types[1] === Matrix{ComplexF64}
466466
# make sure the field type Matrix{Complex{T1}} isn't cached
467467
mutable struct B3890{T2}
468468
x::Matrix{Complex{T2}}
469469
end
470-
@test B3890{Float64}.types[1] === Array{ComplexF64,2}
470+
@test B3890{Float64}.types[1] === Matrix{ComplexF64}
471471

472472
# issue #786
473473
mutable struct Node{T}
@@ -3894,14 +3894,14 @@ f12092(x::Int, y::Int...) = 2
38943894

38953895
# issue #12063
38963896
# NOTE: should have > MAX_TUPLETYPE_LEN arguments
3897-
f12063(tt, g, p, c, b, v, cu::T, d::AbstractArray{T, 2}, ve) where {T} = 1
3897+
f12063(tt, g, p, c, b, v, cu::T, d::AbstractMatrix{T}, ve) where {T} = 1
38983898
f12063(args...) = 2
38993899
g12063() = f12063(0, 0, 0, 0, 0, 0, 0.0, zeros(0,0), Int[])
39003900
@test g12063() == 1
39013901

39023902
# issue #11587
39033903
mutable struct Sampler11587{N}
3904-
clampedpos::Array{Int,2}
3904+
clampedpos::Matrix{Int}
39053905
buf::Array{Float64,N}
39063906
end
39073907
function Sampler11587()
@@ -7435,9 +7435,9 @@ end
74357435
@test repackage28445()
74367436

74377437
# issue #28597
7438-
@test_throws ArgumentError Array{Int, 2}(undef, 0, -10)
7439-
@test_throws ArgumentError Array{Int, 2}(undef, -10, 0)
7440-
@test_throws ArgumentError Array{Int, 2}(undef, -1, -1)
7438+
@test_throws ArgumentError Matrix{Int}(undef, 0, -10)
7439+
@test_throws ArgumentError Matrix{Int}(undef, -10, 0)
7440+
@test_throws ArgumentError Matrix{Int}(undef, -1, -1)
74417441

74427442
# issue #54244
74437443
# test that zero sized array doesn't throw even with large axes

test/offsetarray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,17 @@ PV = view(P, 2:3, :)
247247

248248
# Similar
249249
B = similar(A, Float32)
250-
@test isa(B, OffsetArray{Float32,2})
250+
@test isa(B, OffsetMatrix{Float32})
251251
@test axes(B) === axes(A)
252252
B = similar(A, (3,4))
253-
@test isa(B, Array{Int,2})
253+
@test isa(B, Matrix{Int})
254254
@test size(B) == (3,4)
255255
@test axes(B) === (Base.OneTo(3), Base.OneTo(4))
256256
B = similar(A, (-3:3,1:4))
257-
@test isa(B, OffsetArray{Int,2})
257+
@test isa(B, OffsetMatrix{Int})
258258
@test axes(B) === (OffsetArrays.IdOffsetRange(Base.OneTo(7), -4), OffsetArrays.IdOffsetRange(Base.OneTo(4)))
259259
B = similar(parent(A), (-3:3,1:4))
260-
@test isa(B, OffsetArray{Int,2})
260+
@test isa(B, OffsetMatrix{Int})
261261
@test axes(B) === (OffsetArrays.IdOffsetRange(Base.OneTo(7), -4), OffsetArrays.IdOffsetRange(Base.OneTo(4)))
262262

263263
# Indexing with OffsetArray indices
@@ -923,7 +923,7 @@ end
923923
@test axes(A) == Base.IdentityUnitRange.((2:3, 4:5))
924924

925925
B = reshape(A0, -10:-9, 9:10)
926-
@test isa(B, OffsetArray{Int,2})
926+
@test isa(B, OffsetMatrix{Int})
927927
@test parent(B) == A0
928928
@test axes(B) == Base.IdentityUnitRange.((-10:-9, 9:10))
929929
end

0 commit comments

Comments
 (0)