Skip to content

Commit 9d8c047

Browse files
committed
WIP: through bootstrap!
1 parent ed09c75 commit 9d8c047

File tree

4 files changed

+38
-69
lines changed

4 files changed

+38
-69
lines changed

base/abstractarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ function typed_vcat(::Type{T}, V::AbstractVector...) where T
11271127
for k=1:length(V)
11281128
Vk = V[k]
11291129
p1 = pos+length(Vk)-1
1130-
a[pos:p1] = Vk
1130+
a[pos:p1] .= Vk
11311131
pos = p1+1
11321132
end
11331133
a
@@ -1265,7 +1265,7 @@ function _cat(A, shape::NTuple{N}, catdims, X...) where N
12651265
end
12661266
end
12671267
I::NTuple{N, UnitRange{Int}} = (inds...,)
1268-
A[I...] = x
1268+
A[I...] .= x
12691269
end
12701270
return A
12711271
end

base/array.jl

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -787,56 +787,29 @@ function setindex! end
787787
@eval setindex!(A::Array{T}, x, i1::Int, i2::Int, I::Int...) where {T} =
788788
(@_inline_meta; arrayset($(Expr(:boundscheck)), A, convert(T,x)::T, i1, i2, I...)) # TODO: REMOVE FOR #14770
789789

790-
# These are redundant with the abstract fallbacks but needed for bootstrap
791-
function setindex!(A::Array, x, I::AbstractVector{Int})
792-
@_propagate_inbounds_meta
793-
A === I && (I = copy(I))
794-
for i in I
795-
A[i] = x
796-
end
797-
return A
798-
end
799-
function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int})
800-
@_propagate_inbounds_meta
801-
@boundscheck setindex_shape_check(X, length(I))
802-
count = 1
803-
if X === A
804-
X = copy(X)
805-
I===A && (I = X::typeof(I))
806-
elseif I === A
807-
I = copy(I)
808-
end
809-
for i in I
810-
@inbounds x = X[count]
811-
A[i] = x
812-
count += 1
813-
end
814-
return A
815-
end
816-
817790
# Faster contiguous setindex! with copy!
818-
function setindex!(A::Array{T}, X::Array{T}, I::UnitRange{Int}) where T
819-
@_inline_meta
820-
@boundscheck checkbounds(A, I)
821-
lI = length(I)
822-
@boundscheck setindex_shape_check(X, lI)
823-
if lI > 0
824-
unsafe_copy!(A, first(I), X, 1, lI)
825-
end
826-
return A
827-
end
828-
function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T
829-
@_inline_meta
830-
lI = length(A)
831-
@boundscheck setindex_shape_check(X, lI)
832-
if lI > 0
833-
unsafe_copy!(A, 1, X, 1, lI)
834-
end
835-
return A
836-
end
837-
838-
setindex!(A::Array, x::Number, ::Colon) = fill!(A, x)
839-
setindex!(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) where {T, N} = fill!(A, x)
791+
# function setindex!(A::Array{T}, X::Array{T}, I::UnitRange{Int}) where T
792+
# @_inline_meta
793+
# @boundscheck checkbounds(A, I)
794+
# lI = length(I)
795+
# @boundscheck setindex_shape_check(X, lI)
796+
# if lI > 0
797+
# unsafe_copy!(A, first(I), X, 1, lI)
798+
# end
799+
# return A
800+
# end
801+
# function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T
802+
# @_inline_meta
803+
# lI = length(A)
804+
# @boundscheck setindex_shape_check(X, lI)
805+
# if lI > 0
806+
# unsafe_copy!(A, 1, X, 1, lI)
807+
# end
808+
# return A
809+
# end
810+
#
811+
# setindex!(A::Array, x::Number, ::Colon) = fill!(A, x)
812+
# setindex!(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) where {T, N} = fill!(A, x)
840813

841814
# efficiently grow an array
842815

base/char.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ bswap(x::Char) = Char(bswap(UInt32(x)))
4444

4545
print(io::IO, c::Char) = (write(io, c); nothing)
4646

47-
const hex_chars = UInt8['0':'9';'a':'z']
47+
const hex_chars = [0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
48+
0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
49+
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
50+
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a]
4851

4952
function show(io::IO, c::Char)
5053
if c <= '\\'

base/deprecated.jl

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,25 +1694,18 @@ function _depwarn_for_trailing_indices(t::Tuple)
16941694
end
16951695

16961696
# issue #...: nonscalar indexed assignment of many values to many locations
1697-
@generated function _unsafe_setindex!(::IndexStyle, A::AbstractArray, X::AbstractArray, I::Union{Real,AbstractArray}...)
1698-
N = length(I)
1699-
quote
1700-
if ndims(A) == ndims(X)
1701-
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!)
1702-
else
1703-
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!)
1704-
end
1705-
@nexprs $N d->(I_d = I[d])
1706-
idxlens = @ncall $N index_lengths I
1707-
@ncall $N setindex_shape_check X (d->idxlens[d])
1708-
Xs = start(X)
1709-
@inbounds @nloops $N i d->I_d begin
1710-
v, Xs = next(X, Xs)
1711-
@ncall $N setindex! A v i
1712-
end
1713-
A
1697+
function deprecate_nonscalar_indexed_assignment!(A::AbstractArray, X::AbstractArray, I...)
1698+
if ndims(A) == ndims(X)
1699+
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!)
1700+
A[I...] .= X
1701+
else
1702+
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!)
1703+
A[I...] .= reshape(X, indices(view(A, I...)))
17141704
end
17151705
end
1706+
_unsafe_setindex!(::IndexStyle, A::AbstractArray, X::AbstractArray, I::Union{Real,AbstractArray}...) = deprecate_nonscalar_indexed_assignment!(A, X, I...)
1707+
setindex!(B::BitArray, X::StridedArray, J0::Union{Colon,UnitRange{Int}}) = deprecate_nonscalar_indexed_assignment(B, X, J0)
1708+
setindex!(B::BitArray, X::StridedArray, I0::Union{Colon,UnitRange{Int}}, I::Union{Int,UnitRange{Int},Colon}...) = deprecate_nonscalar_indexed_assignment(B, X, I0, I)
17161709

17171710
# issue #22791
17181711
@deprecate select partialsort

0 commit comments

Comments
 (0)