mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
LibCompress: Discard GZip NAME & COMMENT optional strings
We now discard these strings instead of copying them into a String which we immediately destruct. This should result in both a perf uplift and lower memory usage.
This commit is contained in:
parent
3ef6e31ded
commit
325febf4e5
1 changed files with 17 additions and 4 deletions
|
@ -118,14 +118,27 @@ size_t GzipDecompressor::read(Bytes bytes)
|
||||||
m_input_stream.discard_or_error(length);
|
m_input_stream.discard_or_error(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto discard_string = [&]() {
|
||||||
|
char next_char;
|
||||||
|
do {
|
||||||
|
m_input_stream >> next_char;
|
||||||
|
if (m_input_stream.has_any_error()) {
|
||||||
|
set_fatal_error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (next_char);
|
||||||
|
};
|
||||||
|
|
||||||
if (header.flags & Flags::FNAME) {
|
if (header.flags & Flags::FNAME) {
|
||||||
String original_filename;
|
discard_string();
|
||||||
m_input_stream >> original_filename;
|
if (has_any_error())
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.flags & Flags::FCOMMENT) {
|
if (header.flags & Flags::FCOMMENT) {
|
||||||
String comment;
|
discard_string();
|
||||||
m_input_stream >> comment;
|
if (has_any_error())
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.flags & Flags::FHCRC) {
|
if (header.flags & Flags::FHCRC) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue