Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box the BrotliState value because it is very large #173

Closed
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