Skip to content

Commit

Permalink
Replace unsafe_isdefined with isassigned (#170)
Browse files Browse the repository at this point in the history
This is the standard API
  • Loading branch information
vtjnash authored and timholy committed Dec 21, 2019
1 parent 0efdde2 commit 480fb30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
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

2 comments on commit 480fb30

@timholy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register branch=master

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/7004

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.10 -m "<description of version>" 480fb30eef5eb8e8a07525f926580d9ebf7c2d41
git push origin v0.1.10

Please sign in to comment.