@@ -214,46 +214,15 @@ false
214214isbitsunion (u:: Union ) = allocatedinline (u)
215215isbitsunion (x) = false
216216
217- function _unsetindex! (A:: Array{T} , i:: Int ) where {T}
217+ function _unsetindex! (A:: Array , i:: Int )
218218 @inline
219219 @boundscheck checkbounds (A, i)
220- t = @_gc_preserve_begin A
221- p = Ptr {Ptr{Cvoid}} (pointer (A, i))
222- if ! allocatedinline (T)
223- Intrinsics. atomic_pointerset (p, C_NULL , :monotonic )
224- elseif T isa DataType
225- if ! datatype_pointerfree (T)
226- for j = 1 : Core. sizeof (Ptr{Cvoid}): Core. sizeof (T)
227- Intrinsics. atomic_pointerset (p + j - 1 , C_NULL , :monotonic )
228- end
229- end
230- end
231- @_gc_preserve_end t
220+ @inbounds _unsetindex! (MemoryRef (A. ref, i))
232221 return A
233222end
234223
235224
236225# TODO : deprecate this (aligned_sizeof and/or elsize and/or sizeof(Some{T}) are more correct)
237- """
238- Base.bitsunionsize(U::Union) -> Int
239-
240- For a `Union` of [`isbitstype`](@ref) types, return the size of the largest type; assumes `Base.isbitsunion(U) == true`.
241-
242- # Examples
243- ```jldoctest
244- julia> Base.bitsunionsize(Union{Float64, UInt8})
245- 8
246-
247- julia> Base.bitsunionsize(Union{Float64, UInt8, Int128})
248- 16
249- ```
250- """
251- function bitsunionsize (u:: Union )
252- isinline, sz, _ = uniontype_layout (u)
253- @assert isinline
254- return sz
255- end
256-
257226elsize (:: Type{A} ) where {T,A<: Array{T} } = aligned_sizeof (T)
258227function elsize (:: Type{Ptr{T}} ) where T
259228 # this only must return something valid for values which satisfy is_valid_intrinsic_elptr(T),
@@ -1144,12 +1113,12 @@ function _growat!(a::Vector, i::Integer, delta::Integer)
11441113 unsafe_copyto! (newref, ref, i)
11451114 a. ref = newref
11461115 for j in i: i+ delta- 1
1147- _unsetindex! (a, j)
1116+ @inbounds _unsetindex! (a, j)
11481117 end
11491118 elseif ! prefer_start && memlen >= newmemlen
11501119 unsafe_copyto! (mem, offset+ delta+ i, mem, offset+ i, len- i+ 1 )
11511120 for j in i: i+ delta- 1
1152- _unsetindex! (a, j)
1121+ @inbounds _unsetindex! (a, j)
11531122 end
11541123 else
11551124 # since we will allocate the array in the middle of the memory we need at least 2*delta extra space
@@ -1170,7 +1139,7 @@ function _deletebeg!(a::Vector, delta::Integer)
11701139 len = length (a)
11711140 0 <= delta <= len || throw (ArgumentError (" _deleteat! requires delta in 0:length(a)" ))
11721141 for i in 1 : delta
1173- _unsetindex! (a, i)
1142+ @inbounds _unsetindex! (a, i)
11741143 end
11751144 newlen = len - delta
11761145 if newlen != 0 # if newlen==0 we could accidentally index past the memory
@@ -1185,7 +1154,7 @@ function _deleteend!(a::Vector, delta::Integer)
11851154 0 <= delta <= len || throw (ArgumentError (" _deleteat! requires delta in 0:length(a)" ))
11861155 newlen = len - delta
11871156 for i in newlen+ 1 : len
1188- _unsetindex! (a, i)
1157+ @inbounds _unsetindex! (a, i)
11891158 end
11901159 a. size = (newlen,)
11911160 return
@@ -1782,17 +1751,19 @@ struct Nowhere; end
17821751push! (:: Nowhere , _) = nothing
17831752_growend! (:: Nowhere , _) = nothing
17841753
1785- @inline function _push_deleted! (dltd, a:: Vector , ind)
1786- if @inbounds isassigned (a, ind)
1787- push! (dltd, @inbounds a[ind])
1754+ function _push_deleted! (dltd, a:: Vector , ind)
1755+ @_propagate_inbounds_meta
1756+ if isassigned (a, ind)
1757+ push! (dltd, a[ind])
17881758 else
17891759 _growend! (dltd, 1 )
17901760 end
17911761end
17921762
1793- @inline function _copy_item! (a:: Vector , p, q)
1794- if @inbounds isassigned (a, q)
1795- @inbounds a[p] = a[q]
1763+ function _copy_item! (a:: Vector , p, q)
1764+ @_propagate_inbounds_meta
1765+ if isassigned (a, q)
1766+ a[p] = a[q]
17961767 else
17971768 _unsetindex! (a, p)
17981769 end
@@ -1804,7 +1775,7 @@ function _deleteat!(a::Vector, inds, dltd=Nowhere())
18041775 y === nothing && return a
18051776 (p, s) = y
18061777 checkbounds (a, p)
1807- _push_deleted! (dltd, a, p)
1778+ @inbounds _push_deleted! (dltd, a, p)
18081779 q = p+ 1
18091780 while true
18101781 y = iterate (inds, s)
@@ -1818,14 +1789,14 @@ function _deleteat!(a::Vector, inds, dltd=Nowhere())
18181789 end
18191790 end
18201791 while q < i
1821- _copy_item! (a, p, q)
1792+ @inbounds _copy_item! (a, p, q)
18221793 p += 1 ; q += 1
18231794 end
1824- _push_deleted! (dltd, a, i)
1795+ @inbounds _push_deleted! (dltd, a, i)
18251796 q = i+ 1
18261797 end
18271798 while q <= n
1828- _copy_item! (a, p, q)
1799+ @inbounds _copy_item! (a, p, q)
18291800 p += 1 ; q += 1
18301801 end
18311802 _deleteend! (a, n- p+ 1 )
@@ -1838,7 +1809,7 @@ function deleteat!(a::Vector, inds::AbstractVector{Bool})
18381809 length (inds) == n || throw (BoundsError (a, inds))
18391810 p = 1
18401811 for (q, i) in enumerate (inds)
1841- _copy_item! (a, p, q)
1812+ @inbounds _copy_item! (a, p, q)
18421813 p += ! i
18431814 end
18441815 _deleteend! (a, n- p+ 1 )
0 commit comments