diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 3795ae4eb9df0..2a57715ee20a0 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -1127,7 +1127,7 @@ function typed_vcat(::Type{T}, V::AbstractVector...) where T for k=1:length(V) Vk = V[k] p1 = pos+length(Vk)-1 - a[pos:p1] = Vk + a[pos:p1] .= Vk pos = p1+1 end a @@ -1265,7 +1265,7 @@ function _cat(A, shape::NTuple{N}, catdims, X...) where N end end I::NTuple{N, UnitRange{Int}} = (inds...,) - A[I...] = x + A[I...] .= x end return A end diff --git a/base/array.jl b/base/array.jl index bdd2eaad85c41..d1127642b3301 100644 --- a/base/array.jl +++ b/base/array.jl @@ -787,56 +787,29 @@ function setindex! end @eval setindex!(A::Array{T}, x, i1::Int, i2::Int, I::Int...) where {T} = (@_inline_meta; arrayset($(Expr(:boundscheck)), A, convert(T,x)::T, i1, i2, I...)) # TODO: REMOVE FOR #14770 -# These are redundant with the abstract fallbacks but needed for bootstrap -function setindex!(A::Array, x, I::AbstractVector{Int}) - @_propagate_inbounds_meta - A === I && (I = copy(I)) - for i in I - A[i] = x - end - return A -end -function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int}) - @_propagate_inbounds_meta - @boundscheck setindex_shape_check(X, length(I)) - count = 1 - if X === A - X = copy(X) - I===A && (I = X::typeof(I)) - elseif I === A - I = copy(I) - end - for i in I - @inbounds x = X[count] - A[i] = x - count += 1 - end - return A -end - # Faster contiguous setindex! with copy! -function setindex!(A::Array{T}, X::Array{T}, I::UnitRange{Int}) where T - @_inline_meta - @boundscheck checkbounds(A, I) - lI = length(I) - @boundscheck setindex_shape_check(X, lI) - if lI > 0 - unsafe_copy!(A, first(I), X, 1, lI) - end - return A -end -function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T - @_inline_meta - lI = length(A) - @boundscheck setindex_shape_check(X, lI) - if lI > 0 - unsafe_copy!(A, 1, X, 1, lI) - end - return A -end - -setindex!(A::Array, x::Number, ::Colon) = fill!(A, x) -setindex!(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) where {T, N} = fill!(A, x) +# function setindex!(A::Array{T}, X::Array{T}, I::UnitRange{Int}) where T +# @_inline_meta +# @boundscheck checkbounds(A, I) +# lI = length(I) +# @boundscheck setindex_shape_check(X, lI) +# if lI > 0 +# unsafe_copy!(A, first(I), X, 1, lI) +# end +# return A +# end +# function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T +# @_inline_meta +# lI = length(A) +# @boundscheck setindex_shape_check(X, lI) +# if lI > 0 +# unsafe_copy!(A, 1, X, 1, lI) +# end +# return A +# end +# +# setindex!(A::Array, x::Number, ::Colon) = fill!(A, x) +# setindex!(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) where {T, N} = fill!(A, x) # efficiently grow an array diff --git a/base/char.jl b/base/char.jl index ea7334eb0679e..ad3a865b2b7dc 100644 --- a/base/char.jl +++ b/base/char.jl @@ -44,7 +44,10 @@ bswap(x::Char) = Char(bswap(UInt32(x))) print(io::IO, c::Char) = (write(io, c); nothing) -const hex_chars = UInt8['0':'9';'a':'z'] +const hex_chars = [0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, + 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a] function show(io::IO, c::Char) if c <= '\\' diff --git a/base/deprecated.jl b/base/deprecated.jl index f8b4a0b3496d2..4e1d4f5d75af1 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1694,25 +1694,18 @@ function _depwarn_for_trailing_indices(t::Tuple) end # issue #...: nonscalar indexed assignment of many values to many locations -@generated function _unsafe_setindex!(::IndexStyle, A::AbstractArray, X::AbstractArray, I::Union{Real,AbstractArray}...) - N = length(I) - quote - if ndims(A) == ndims(X) - depwarn("using nonscalar indexed assignment to implicitly broadcast the values of an array to many indices is deprecated. Use `A[I...] .= values` to explicitly opt-in to broadcasting.", :setindex!) - else - depwarn("using nonscalar indexed assignment to implicitly broadcast the values of an array to many indices is deprecated. Use `A[I...] .= reshape(values` to explicitly opt-in to broadcasting.", :setindex!) - end - @nexprs $N d->(I_d = I[d]) - idxlens = @ncall $N index_lengths I - @ncall $N setindex_shape_check X (d->idxlens[d]) - Xs = start(X) - @inbounds @nloops $N i d->I_d begin - v, Xs = next(X, Xs) - @ncall $N setindex! A v i - end - A +function deprecate_nonscalar_indexed_assignment!(A::AbstractArray, X::AbstractArray, I...) + if ndims(A) == ndims(X) + depwarn("using `A[I...] = X` to implicitly broadcast the elements of `X` to many locations in `A` is deprecated. Use `A[I...] .= X` to explicitly opt-in to broadcasting.", :setindex!) + A[I...] .= X + else + depwarn("using `A[I...] = X` to implicitly broadcast the elements of `X` to many locations in `A` is deprecated. Use `A[I...] .= reshape(X, indices(view(A, I...)))` to explicitly opt-in to broadcasting.", :setindex!) + A[I...] .= reshape(X, indices(view(A, I...))) end end +_unsafe_setindex!(::IndexStyle, A::AbstractArray, X::AbstractArray, I::Union{Real,AbstractArray}...) = deprecate_nonscalar_indexed_assignment!(A, X, I...) +setindex!(B::BitArray, X::StridedArray, J0::Union{Colon,UnitRange{Int}}) = deprecate_nonscalar_indexed_assignment(B, X, J0) +setindex!(B::BitArray, X::StridedArray, I0::Union{Colon,UnitRange{Int}}, I::Union{Int,UnitRange{Int},Colon}...) = deprecate_nonscalar_indexed_assignment(B, X, I0, I) # issue #22791 @deprecate select partialsort