Skip to content

Commit

Permalink
Use packedsizeof instead of overloaded Base.sizeof
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasgal committed May 27, 2020
1 parent b05bb8a commit d07b03a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/root.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ end


function splitup(data::Vector{UInt8}, offsets, T::Type; skipbytes=0, primitive=false)
elsize = sizeof(T)
elsize = packedsizeof(T)
out = sizehint!(Vector{Vector{T}}(), length(offsets))
lengths = diff(offsets)
push!(lengths, length(data) - offsets[end] + offsets[1]) # yay ;)
Expand All @@ -170,7 +170,8 @@ function splitup(data::Vector{UInt8}, offsets, T::Type; skipbytes=0, primitive=f
push!(out, reinterpret(T, data[skipbytes+1:skipbytes+Int32((l - skipbytes))]))
else
skip(io, skipbytes)
push!(out, [readtype(io, T) for _ in 1:((l - skipbytes)/elsize)])
n = (l - skipbytes) / elsize
push!(out, [readtype(io, T) for _ in 1:n])
end
end
out
Expand Down

0 comments on commit d07b03a

Please sign in to comment.