diff --git a/base/array.jl b/base/array.jl index dc9592b743030..aeda4e649907e 100644 --- a/base/array.jl +++ b/base/array.jl @@ -185,13 +185,6 @@ function vect(X...) return T[X...] end -size(a::Array, d::Integer) = size(a, Int(d)::Int) -function size(a::Array, d::Int) - d < 1 && error("arraysize: dimension out of range") - sz = getfield(a, :size) - return d > length(sz) ? 1 : getfield(sz, d, false) # @inbounds -end - asize_from(a::Array, n) = n > ndims(a) ? () : (size(a,n), asize_from(a, n+1)...) allocatedinline(@nospecialize T::Type) = (@_total_meta; ccall(:jl_stored_inline, Cint, (Any,), T) != Cint(0)) diff --git a/base/bitarray.jl b/base/bitarray.jl index 5a3469fa7c7a2..9770fe0a336c5 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -104,11 +104,6 @@ length(B::BitArray) = B.len size(B::BitVector) = (B.len,) size(B::BitArray) = B.dims -@inline function size(B::BitVector, d::Integer) - d < 1 && throw_boundserror(size(B), d) - ifelse(d == 1, B.len, 1) -end - isassigned(B::BitArray, i::Int) = 1 <= i <= length(B) IndexStyle(::Type{<:BitArray}) = IndexLinear() diff --git a/base/essentials.jl b/base/essentials.jl index 84b8f8999038c..59dfe3ded228b 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -9,7 +9,7 @@ const Bottom = Union{} # Define minimal array interface here to help code used in macros: size(a::Array) = getfield(a, :size) length(t::AbstractArray) = (@inline; prod(size(t))) -length(a::GenericMemory) = getfield(a, :length) +size(a::GenericMemory) = (getfield(a, :length),) throw_boundserror(A, I) = (@noinline; throw(BoundsError(A, I))) # multidimensional getindex will be defined later on diff --git a/base/genericmemory.jl b/base/genericmemory.jl index b180462115f41..842d7aacc879c 100644 --- a/base/genericmemory.jl +++ b/base/genericmemory.jl @@ -61,13 +61,6 @@ AtomicMemory using Core: memoryrefoffset, memoryref_isassigned # import more functions which were not essential -size(a::GenericMemory, d::Int) = - d < 1 ? error("dimension out of range") : - d == 1 ? length(a) : - 1 -size(a::GenericMemory, d::Integer) = size(a, convert(Int, d)) -size(a::GenericMemory) = (length(a),) - IndexStyle(::Type{<:GenericMemory}) = IndexLinear() parent(ref::GenericMemoryRef) = ref.mem diff --git a/base/indices.jl b/base/indices.jl index 4f0d9ad14a1b6..0d0e56b12be4b 100644 --- a/base/indices.jl +++ b/base/indices.jl @@ -392,7 +392,6 @@ axes1(S::Slice{<:AbstractOneTo{<:Integer}}) = S.indices first(S::Slice) = first(S.indices) last(S::Slice) = last(S.indices) size(S::Slice) = (length(S.indices),) -length(S::Slice) = length(S.indices) getindex(S::Slice, i::Int) = (@inline; @boundscheck checkbounds(S, i); i) getindex(S::Slice, i::AbstractUnitRange{<:Integer}) = (@inline; @boundscheck checkbounds(S, i); i) getindex(S::Slice, i::StepRange{<:Integer}) = (@inline; @boundscheck checkbounds(S, i); i) @@ -420,7 +419,6 @@ axes1(S::IdentityUnitRange{<:AbstractOneTo{<:Integer}}) = S.indices first(S::IdentityUnitRange) = first(S.indices) last(S::IdentityUnitRange) = last(S.indices) size(S::IdentityUnitRange) = (length(S.indices),) -length(S::IdentityUnitRange) = length(S.indices) unsafe_length(S::IdentityUnitRange) = unsafe_length(S.indices) getindex(S::IdentityUnitRange, i::Integer) = (@inline; @boundscheck checkbounds(S, i); convert(eltype(S), i)) getindex(S::IdentityUnitRange, i::Bool) = throw(ArgumentError("invalid index: $i of type Bool")) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 1ca25776ba636..fdfcafef1099d 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -485,8 +485,6 @@ module IteratorsMD size(iter::CartesianIndices) = map(length, iter.indices) - length(iter::CartesianIndices) = prod(size(iter)) - # make CartesianIndices a multidimensional range Base.step(iter::CartesianIndices) = CartesianIndex(map(step, iter.indices)) @@ -836,7 +834,6 @@ LogicalIndex(mask::AbstractVector{Bool}) = LogicalIndex{Int, typeof(mask)}(mask) LogicalIndex(mask::AbstractArray{Bool, N}) where {N} = LogicalIndex{CartesianIndex{N}, typeof(mask)}(mask) LogicalIndex{Int}(mask::AbstractArray) = LogicalIndex{Int, typeof(mask)}(mask) size(L::LogicalIndex) = (L.sum,) -length(L::LogicalIndex) = L.sum collect(L::LogicalIndex) = [i for i in L] show(io::IO, r::LogicalIndex) = print(io,collect(r)) print_array(io::IO, X::LogicalIndex) = print_array(io, collect(X)) diff --git a/base/strings/basic.jl b/base/strings/basic.jl index a6015fcd12c99..3bacb3aa12705 100644 --- a/base/strings/basic.jl +++ b/base/strings/basic.jl @@ -791,9 +791,8 @@ struct CodeUnits{T,S<:AbstractString} <: DenseVector{T} CodeUnits(s::S) where {S<:AbstractString} = new{codeunit(s),S}(s) end -length(s::CodeUnits) = ncodeunits(s.s) sizeof(s::CodeUnits{T}) where {T} = ncodeunits(s.s) * sizeof(T) -size(s::CodeUnits) = (length(s),) +size(s::CodeUnits) = (ncodeunits(s.s),) elsize(s::Type{<:CodeUnits{T}}) where {T} = sizeof(T) @propagate_inbounds getindex(s::CodeUnits, i::Int) = codeunit(s.s, i) IndexStyle(::Type{<:CodeUnits}) = IndexLinear() diff --git a/stdlib/Random/src/Random.jl b/stdlib/Random/src/Random.jl index 9e05475b48c20..cc598094b1956 100644 --- a/stdlib/Random/src/Random.jl +++ b/stdlib/Random/src/Random.jl @@ -309,7 +309,6 @@ struct UnsafeView{T} <: DenseArray{T,1} len::Int end -Base.length(a::UnsafeView) = a.len Base.getindex(a::UnsafeView, i::Int) = unsafe_load(a.ptr, i) Base.setindex!(a::UnsafeView, x, i::Int) = unsafe_store!(a.ptr, x, i) Base.pointer(a::UnsafeView) = a.ptr