Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/codec/brotli/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ use std::{
use brotli::{enc::StandardAlloc, BrotliDecompressStream, BrotliResult, BrotliState};

pub struct BrotliDecoder {
state: BrotliState<StandardAlloc, StandardAlloc, StandardAlloc>,
// `BrotliState` is very large (over 2kb) which is why we're boxing it.
state: Box<BrotliState<StandardAlloc, StandardAlloc, StandardAlloc>>,
}

impl BrotliDecoder {
pub(crate) fn new() -> Self {
Self {
state: BrotliState::new(
state: Box::new(BrotliState::new(
StandardAlloc::default(),
StandardAlloc::default(),
StandardAlloc::default(),
),
)),
}
}

Expand Down Expand Up @@ -57,11 +58,11 @@ impl BrotliDecoder {

impl Decode for BrotliDecoder {
fn reinit(&mut self) -> Result<()> {
self.state = BrotliState::new(
self.state = Box::new(BrotliState::new(
StandardAlloc::default(),
StandardAlloc::default(),
StandardAlloc::default(),
);
));
Ok(())
}

Expand Down