Skip to content

Commit 4dd7471

Browse files
committed
Revert "Merge pull request #22441 from JuliaLang/jq/array-union-bits"
This reverts commit d126c66, reversing changes made to a945af3.
1 parent feaa2f6 commit 4dd7471

13 files changed

+137
-702
lines changed

base/array.jl

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,8 @@ size(a::Array{<:Any,N}) where {N} = (@_inline_meta; ntuple(M -> size(a, M), Val(
109109

110110
asize_from(a::Array, n) = n > ndims(a) ? () : (arraysize(a,n), asize_from(a, n+1)...)
111111

112-
"""
113-
Base.isbitsunion(::Type{T})
114-
115-
Return whether a type is an "is-bits" Union type, meaning each type included in a Union is `isbits`.
116-
"""
117-
function isbitsunion end
118-
119-
function isbitsunion(U::Union)
120-
for u in Base.uniontypes(U)
121-
isbits(u) || return false
122-
end
123-
return true
124-
end
125-
isbitsunion(T) = false
126-
127-
"""
128-
Base.bitsunionsize(U::Union)
129-
130-
For a Union of `isbits` types, return the size of the largest type.
131-
"""
132-
function bitsunionsize(U::Union)
133-
sz = 0
134-
for u in Base.uniontypes(U)
135-
sz = max(sz, sizeof(u))
136-
end
137-
return sz
138-
end
139-
140112
length(a::Array) = arraylen(a)
141-
elsize(a::Array{T}) where {T} = isbits(T) ? sizeof(T) : (isbitsunion(T) ? bitsunionsize(T) : sizeof(Ptr))
113+
elsize(a::Array{T}) where {T} = isbits(T) ? sizeof(T) : sizeof(Ptr)
142114
sizeof(a::Array) = Core.sizeof(a)
143115

144116
function isassigned(a::Array, i::Int...)
@@ -215,7 +187,7 @@ original.
215187
copy(a::T) where {T<:Array} = ccall(:jl_array_copy, Ref{T}, (Any,), a)
216188

217189
function reinterpret(::Type{T}, a::Array{S,1}) where T where S
218-
nel = Int(div(length(a) * sizeof(S), sizeof(T)))
190+
nel = Int(div(length(a)*sizeof(S),sizeof(T)))
219191
# TODO: maybe check that remainder is zero?
220192
return reinterpret(T, a, (nel,))
221193
end
@@ -234,7 +206,7 @@ function reinterpret(::Type{T}, a::Array{S}, dims::NTuple{N,Int}) where T where
234206
end
235207
isbits(T) || throwbits(S, T, T)
236208
isbits(S) || throwbits(S, T, S)
237-
nel = div(length(a) * sizeof(S), sizeof(T))
209+
nel = div(length(a)*sizeof(S),sizeof(T))
238210
if prod(dims) != nel
239211
_throw_dmrsa(dims, nel)
240212
end

0 commit comments

Comments
 (0)