mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: share decompressor buffer (#5777)
This commit is contained in:
@ -115,20 +115,11 @@ fn generate_from_compact(fields: &FieldList, ident: &Ident, is_zstd: bool) -> To
|
||||
quote! {
|
||||
if flags.__zstd() != 0 {
|
||||
#decompressor.with(|decompressor| {
|
||||
let mut decompressor = decompressor.borrow_mut();
|
||||
|
||||
let mut tmp: Vec<u8> = Vec::with_capacity(300);
|
||||
|
||||
while let Err(err) = decompressor.decompress_to_buffer(&buf[..], &mut tmp) {
|
||||
let err = err.to_string();
|
||||
if !err.contains("Destination buffer is too small") {
|
||||
panic!("Failed to decompress: {}", err);
|
||||
}
|
||||
tmp.reserve(tmp.capacity() + 10_000);
|
||||
}
|
||||
let decompressor = &mut decompressor.borrow_mut();
|
||||
let decompressed = decompressor.decompress(buf);
|
||||
let mut original_buf = buf;
|
||||
|
||||
let mut buf: &[u8] = tmp.as_slice();
|
||||
let mut buf: &[u8] = decompressed;
|
||||
#(#lines)*
|
||||
(obj, original_buf)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user