use super::*;
impl<T> Default for PooledSlice<T> {
#[inline(always)]
fn default() -> Self {
Self(Vec::new())
}
}
impl<T> SliceWrapper<T> for PooledSlice<T> {
#[inline(always)]
fn slice(&self) -> &[T] {
let Self(inner) = self;
inner.as_slice()
}
}
impl<T> SliceWrapperMut<T> for PooledSlice<T> {
#[inline(always)]
fn slice_mut(&mut self) -> &mut [T] {
let Self(inner) = self;
inner.as_mut_slice()
}
}
impl Drop for BrotliEncoderGuard {
#[inline(always)]
fn drop(&mut self) {
let Self(state) = self;
BrotliEncoderDestroyInstance(state);
}
}
impl BrotliAlloc for BrotliTlAlloc {}
impl Allocator<u8> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<u8>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_u8)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_u8);
}
}
impl Allocator<u16> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<u16>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_u16)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_u16);
}
}
impl Allocator<i32> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<i32>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_i32)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_i32);
}
}
impl Allocator<u32> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<u32>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_u32)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_u32);
}
}
impl Allocator<u64> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<u64>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_u64)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_u64);
}
}
impl Allocator<Command> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<Command>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_command)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_command);
}
}
impl Allocator<floatX> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<floatX>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_float)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_float);
}
}
impl Allocator<v8> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<v8>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_v8)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_v8);
}
}
impl Allocator<s16> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<s16>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_s16)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_s16);
}
}
impl Allocator<PDF> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<PDF>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_pdf)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_pdf);
}
}
impl Allocator<StaticCommand> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<StaticCommand>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_static_command
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_static_command
});
}
}
impl Allocator<HistogramLiteral> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<HistogramLiteral>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_hist_literal
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_hist_literal
});
}
}
impl Allocator<HistogramCommand> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<HistogramCommand>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_hist_command
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_hist_command
});
}
}
impl Allocator<HistogramDistance> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<HistogramDistance>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_hist_distance
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_hist_distance
});
}
}
impl Allocator<HistogramPair> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<HistogramPair>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_hist_pair)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| &mut pool.buf_hist_pair);
}
}
impl Allocator<ContextType> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<ContextType>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_context_type
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_context_type
});
}
}
impl Allocator<HuffmanTree> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<HuffmanTree>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_huffman_tree
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_huffman_tree
});
}
}
impl Allocator<ZopfliNode> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<ZopfliNode>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| &mut pool.buf_zopfli_node)
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_zopfli_node
});
}
}
impl Allocator<HuffmanCode> for BrotliTlAlloc {
type AllocatedMemory = PooledSlice<HuffmanCode>;
#[inline(always)]
fn alloc_cell(&mut self, len: usize) -> Self::AllocatedMemory {
alloc_from_pool(len, |pool: &mut BrotliBufferPool| {
&mut pool.buf_huffman_code
})
}
#[inline(always)]
fn free_cell(&mut self, data: Self::AllocatedMemory) {
free_to_pool(data, |pool: &mut BrotliBufferPool| {
&mut pool.buf_huffman_code
});
}
}