Skip to content
Permalink
Browse files
Fix slight perf hit when checking validity bitmap (#176)
Fixes #131. Dip me in mustard and call me a hotdog, cuz I can't tell
how/why `divrem(i - 1, 8) .+ (1, 1)` ends up being ~30% faster than
`fldmod1(i, 8)`. It'd probably be worth looking into it more, but it
works for now. The divrem code is @ExpandingMan 's code from his
arrow/feather code.
  • Loading branch information
quinnj committed Apr 15, 2021
1 parent 8619e05 commit c5c77e6c025c94d983814e0f1cd79e66473963c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
@@ -164,7 +164,7 @@ end
# 2) parent array is also empty, so "all" elements are valid
p.nc == 0 && return true
# translate element index to bitpacked byte index
a, b = fldmod1(i, 8)
a, b = divrem(i-1, 8) .+ (1,1)
@inbounds byte = p.bytes[p.pos + a - 1]
# check individual bit of byte
return getbit(byte, b)
@@ -54,7 +54,7 @@ function writearray(io::IO, ::Type{T}, col) where {T}
return n
end

getbit(v::UInt8, n::Integer) = Bool((v & 0x02^(n - 1)) >> (n - 1))
getbit(v::UInt8, n::Integer) = (v & (1 << (n - 1))) > 0x00

function setbit(v::UInt8, b::Bool, n::Integer)
if b

0 comments on commit c5c77e6

Please sign in to comment.