Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using the broken unsafe_isdefined function #170

Merged
merged 2 commits into from
Dec 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/dataio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function write_data(io::MmapIO, f::JLDFile, data::Array{T}, odr::S, ::HasReferen
cp = IndirectPointer(io, p)

for i = 1:length(data)
if (isconcretetype(T) && isbitstype(T)) || unsafe_isdefined(data, i)
if isassigned(data, i)
@inbounds h5convert!(cp, odr, f, data[i], wsession)
else
@inbounds h5convert_uninitialized!(cp, odr)
Expand Down Expand Up @@ -261,7 +261,7 @@ function write_data(io::BufferedWriter, f::JLDFile, data::Array{T}, odr::S,
position = io.position[]
cp = Ptr{Cvoid}(pointer(io.buffer, position+1))
@simd for i = 1:length(data)
if (isconcretetype(T) && isbitstype(T)) || unsafe_isdefined(data, i)
if isassigned(data, i)
@inbounds h5convert!(cp, odr, f, data[i], wsession)
else
@inbounds h5convert_uninitialized!(cp, odr)
Expand All @@ -279,7 +279,7 @@ function write_data(io::IOStream, f::JLDFile, data::Array{T}, odr::S, wm::DataMo
pos = position(io)
cp = Ptr{Cvoid}(pointer(buf))
@simd for i = 1:length(data)
if (isconcretetype(T) && isbitstype(T)) || unsafe_isdefined(data, i)
if isassigned(data, i)
@inbounds h5convert!(cp, odr, f, data[i], wsession)
else
@inbounds h5convert_uninitialized!(cp, odr)
Expand Down
4 changes: 0 additions & 4 deletions src/datasets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ function payload_size_without_storage_message(dataspace::WriteDataspace, datatyp
sz
end

# Like isdefined, but assumes arr is a pointer array, and can be inlined
unsafe_isdefined(arr::Array, i::Int) =
unsafe_load(Ptr{Ptr{Cvoid}}(pointer(arr)+(i-1)*sizeof(Ptr{Cvoid}))) != Ptr{Cvoid}(0)

function deflate_data(f::JLDFile, data::Array{T}, odr::S, wsession::JLDWriteSession) where {T,S}
buf = Vector{UInt8}(undef, odr_sizeof(odr) * length(data))
cp = Ptr{Cvoid}(pointer(buf))
Expand Down