add inline to bitpacker (#1064)

This commit is contained in:
PSeitz
2021-05-31 16:15:41 +02:00
committed by GitHub
parent 41ea14840d
commit 2aad0ced77
2 changed files with 4 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ impl BitPacker {
} }
} }
#[inline]
pub fn write<TWrite: io::Write>( pub fn write<TWrite: io::Write>(
&mut self, &mut self,
val: u64, val: u64,
@@ -79,6 +80,7 @@ impl BitUnpacker {
} }
} }
#[inline]
pub fn get(&self, idx: u64, data: &[u8]) -> u64 { pub fn get(&self, idx: u64, data: &[u8]) -> u64 {
if self.num_bits == 0 { if self.num_bits == 0 {
return 0u64; return 0u64;

View File

@@ -80,6 +80,7 @@ impl BlockedBitpacker {
* std::mem::size_of_val(&self.buffer.get(0).cloned().unwrap_or_default()) * std::mem::size_of_val(&self.buffer.get(0).cloned().unwrap_or_default())
} }
#[inline]
pub fn add(&mut self, val: u64) { pub fn add(&mut self, val: u64) {
self.buffer.push(val); self.buffer.push(val);
if self.buffer.len() == BLOCK_SIZE as usize { if self.buffer.len() == BLOCK_SIZE as usize {
@@ -122,6 +123,7 @@ impl BlockedBitpacker {
.resize(self.compressed_blocks.len() + 8, 0); // add padding for bitpacker .resize(self.compressed_blocks.len() + 8, 0); // add padding for bitpacker
} }
} }
#[inline]
pub fn get(&self, idx: usize) -> u64 { pub fn get(&self, idx: usize) -> u64 {
let metadata_pos = idx / BLOCK_SIZE as usize; let metadata_pos = idx / BLOCK_SIZE as usize;
let pos_in_block = idx % BLOCK_SIZE as usize; let pos_in_block = idx % BLOCK_SIZE as usize;