Skip to content

Commit 9545f2b

Browse files
committed
WIP: through bootstrap!
1 parent 9df3029 commit 9545f2b

File tree

5 files changed

+42
-73
lines changed

5 files changed

+42
-73
lines changed

base/abstractarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ function typed_vcat(::Type{T}, V::AbstractVector...) where T
11261126
for k=1:length(V)
11271127
Vk = V[k]
11281128
p1 = pos+length(Vk)-1
1129-
a[pos:p1] = Vk
1129+
a[pos:p1] .= Vk
11301130
pos = p1+1
11311131
end
11321132
a
@@ -1264,7 +1264,7 @@ function _cat(A, shape::NTuple{N}, catdims, X...) where N
12641264
end
12651265
end
12661266
I::NTuple{N, UnitRange{Int}} = (inds...,)
1267-
A[I...] = x
1267+
A[I...] .= x
12681268
end
12691269
return A
12701270
end

base/array.jl

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -678,56 +678,29 @@ function setindex! end
678678
@eval setindex!(A::Array{T}, x, i1::Int, i2::Int, I::Int...) where {T} =
679679
(@_inline_meta; arrayset($(Expr(:boundscheck)), A, convert(T,x)::T, i1, i2, I...))
680680

681-
# These are redundant with the abstract fallbacks but needed for bootstrap
682-
function setindex!(A::Array, x, I::AbstractVector{Int})
683-
@_propagate_inbounds_meta
684-
A === I && (I = copy(I))
685-
for i in I
686-
A[i] = x
687-
end
688-
return A
689-
end
690-
function setindex!(A::Array, X::AbstractArray, I::AbstractVector{Int})
691-
@_propagate_inbounds_meta
692-
@boundscheck setindex_shape_check(X, length(I))
693-
count = 1
694-
if X === A
695-
X = copy(X)
696-
I===A && (I = X::typeof(I))
697-
elseif I === A
698-
I = copy(I)
699-
end
700-
for i in I
701-
@inbounds x = X[count]
702-
A[i] = x
703-
count += 1
704-
end
705-
return A
706-
end
707-
708-
# Faster contiguous setindex! with copyto!
709-
function setindex!(A::Array{T}, X::Array{T}, I::UnitRange{Int}) where T
710-
@_inline_meta
711-
@boundscheck checkbounds(A, I)
712-
lI = length(I)
713-
@boundscheck setindex_shape_check(X, lI)
714-
if lI > 0
715-
unsafe_copyto!(A, first(I), X, 1, lI)
716-
end
717-
return A
718-
end
719-
function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T
720-
@_inline_meta
721-
lI = length(A)
722-
@boundscheck setindex_shape_check(X, lI)
723-
if lI > 0
724-
unsafe_copyto!(A, 1, X, 1, lI)
725-
end
726-
return A
727-
end
728-
729-
setindex!(A::Array, x::Number, ::Colon) = fill!(A, x)
730-
setindex!(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) where {T, N} = fill!(A, x)
681+
# Faster contiguous setindex! with copy!
682+
# function setindex!(A::Array{T}, X::Array{T}, I::UnitRange{Int}) where T
683+
# @_inline_meta
684+
# @boundscheck checkbounds(A, I)
685+
# lI = length(I)
686+
# @boundscheck setindex_shape_check(X, lI)
687+
# if lI > 0
688+
# unsafe_copy!(A, first(I), X, 1, lI)
689+
# end
690+
# return A
691+
# end
692+
# function setindex!(A::Array{T}, X::Array{T}, c::Colon) where T
693+
# @_inline_meta
694+
# lI = length(A)
695+
# @boundscheck setindex_shape_check(X, lI)
696+
# if lI > 0
697+
# unsafe_copy!(A, 1, X, 1, lI)
698+
# end
699+
# return A
700+
# end
701+
#
702+
# setindex!(A::Array, x::Number, ::Colon) = fill!(A, x)
703+
# setindex!(A::Array{T, N}, x::Number, ::Vararg{Colon, N}) where {T, N} = fill!(A, x)
731704

732705
# efficiently grow an array
733706

base/char.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ widen(::Type{Char}) = Char
9797

9898
print(io::IO, c::Char) = (write(io, c); nothing)
9999

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

102105
function show(io::IO, c::Char)
103106
if c <= '\\'

base/deprecated.jl

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

16711671
# issue #...: nonscalar indexed assignment of many values to many locations
1672-
@generated function _unsafe_setindex!(::IndexStyle, A::AbstractArray, X::AbstractArray, I::Union{Real,AbstractArray}...)
1673-
N = length(I)
1674-
quote
1675-
if ndims(A) == ndims(X)
1676-
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!)
1677-
else
1678-
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!)
1679-
end
1680-
@nexprs $N d->(I_d = I[d])
1681-
idxlens = @ncall $N index_lengths I
1682-
@ncall $N setindex_shape_check X (d->idxlens[d])
1683-
Xs = start(X)
1684-
@inbounds @nloops $N i d->I_d begin
1685-
v, Xs = next(X, Xs)
1686-
@ncall $N setindex! A v i
1687-
end
1688-
A
1672+
function deprecate_nonscalar_indexed_assignment!(A::AbstractArray, X::AbstractArray, I...)
1673+
if ndims(A) == ndims(X)
1674+
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!)
1675+
A[I...] .= X
1676+
else
1677+
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!)
1678+
A[I...] .= reshape(X, indices(view(A, I...)))
16891679
end
16901680
end
1681+
_unsafe_setindex!(::IndexStyle, A::AbstractArray, X::AbstractArray, I::Union{Real,AbstractArray}...) = deprecate_nonscalar_indexed_assignment!(A, X, I...)
1682+
setindex!(B::BitArray, X::StridedArray, J0::Union{Colon,UnitRange{Int}}) = deprecate_nonscalar_indexed_assignment(B, X, J0)
1683+
setindex!(B::BitArray, X::StridedArray, I0::Union{Colon,UnitRange{Int}}, I::Union{Int,UnitRange{Int},Colon}...) = deprecate_nonscalar_indexed_assignment(B, X, I0, I)
16911684

16921685
# issue #22791
16931686
@deprecate select partialsort

base/multidimensional.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,12 +1473,12 @@ end
14731473
# contiguous multidimensional indexing: if the first dimension is a range,
14741474
# we can get some performance from using copy_chunks!
14751475
function broadcast!(::typeof(identity), B::BitArray, X::StridedArray)
1476-
size(B) == size(X) || return Broadcast.broadcast_c!(identity, containertype(B), containertype(X), B, X)
1476+
size(B) == size(X) || return _broadcast!(identity, B, X)
14771477
copy_to_bitarray_chunks!(B.chunks, 1, X, 1, length(B))
14781478
return B
14791479
end
14801480
function broadcast!(::typeof(identity), V::SubArray{<:Any,<:Any,<:BitArray,<:Tuple{AbstractUnitRange}}, X::StridedArray)
1481-
size(V) == size(X) || return Broadcast.broadcast_c!(identity, containertype(V), containertype(X), V, X)
1481+
size(V) == size(X) || _broadcast!(identity, B, X)
14821482
B = V.parent
14831483
I0 = V.indexes[1]
14841484
l0 = length(I0)
@@ -1491,7 +1491,7 @@ end
14911491
V::SubArray{<:Any,<:Any,<:BitArray,<:Tuple{AbstractUnitRange,Vararg{Union{AbstractUnitRange,Int}}}}, X::StridedArray)
14921492
N = length(I)
14931493
quote
1494-
size(V) == size(X) || return Broadcast.broadcast_c!(identity, containertype(V), containertype(X), V, X)
1494+
size(V) == size(X) || return _broadcast(identity, V, X)
14951495
B = V.parent
14961496
I0 = V.indexes[1]
14971497
I = tail(V.indexes)

0 commit comments

Comments
 (0)