Compress the debug data for quite a large saving

This commit is contained in:
Gwilym Inzani 2024-04-03 13:38:49 +01:00
parent 2475b5676a
commit 25e15baa2b
3 changed files with 38 additions and 1 deletions

32
agb-gbafix/Cargo.lock generated
View file

@ -9,6 +9,7 @@ dependencies = [
"anyhow",
"clap",
"elf",
"lz4_flex",
"rmp-serde",
]
@ -78,6 +79,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.3"
@ -117,6 +124,15 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b"
[[package]]
name = "lz4_flex"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5"
dependencies = [
"twox-hash",
]
[[package]]
name = "num-traits"
version = "0.2.18"
@ -192,6 +208,12 @@ dependencies = [
"syn",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.11.0"
@ -209,6 +231,16 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "twox-hash"
version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if",
"static_assertions",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"

View file

@ -12,6 +12,7 @@ elf = "0.7"
anyhow = "1"
clap = "4"
rmp-serde = "1"
lz4_flex = "0.11"
[profile.dev]
opt-level = 3

View file

@ -165,7 +165,11 @@ fn write_debug<W: Write>(
}
let mut debug_data = vec![];
rmp_serde::encode::write(&mut debug_data, &debug_sections)?;
{
let mut compressed_writer = lz4_flex::frame::FrameEncoder::new(&mut debug_data);
rmp_serde::encode::write(&mut compressed_writer, &debug_sections)?;
compressed_writer.flush()?;
}
output.write_all(&debug_data)?;
output.write_all(&(debug_data.len() as u32).to_le_bytes())?;