mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/GIF: Avoid copying LZW subblocks twice
I started to write that in order to remove the manual copy of the data but that should produce some performance gains as well.
This commit is contained in:
parent
7aa76e6c9f
commit
7a55c4af0e
Notes:
sideshowbarker
2024-07-16 18:06:41 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/7a55c4af0e Pull-request: https://github.com/SerenityOS/serenity/pull/24261 Reviewed-by: https://github.com/nico ✅
1 changed files with 3 additions and 7 deletions
|
@ -33,7 +33,7 @@ struct GIFImageDescriptor {
|
|||
bool interlaced { false };
|
||||
Color color_map[256];
|
||||
u8 lzw_min_code_size { 0 };
|
||||
Vector<u8> lzw_encoded_bytes;
|
||||
ByteBuffer lzw_encoded_bytes;
|
||||
|
||||
// Fields from optional graphic control extension block
|
||||
enum DisposalMethod : u8 {
|
||||
|
@ -357,12 +357,8 @@ static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
|
|||
if (lzw_encoded_bytes_expected == 0)
|
||||
break;
|
||||
|
||||
Array<u8, 256> buffer;
|
||||
TRY(context.stream.read_until_filled(buffer.span().trim(lzw_encoded_bytes_expected)));
|
||||
|
||||
for (int i = 0; i < lzw_encoded_bytes_expected; ++i) {
|
||||
image->lzw_encoded_bytes.append(buffer[i]);
|
||||
}
|
||||
auto const lzw_subblock = TRY(image->lzw_encoded_bytes.get_bytes_for_writing(lzw_encoded_bytes_expected));
|
||||
TRY(context.stream.read_until_filled(lzw_subblock));
|
||||
}
|
||||
|
||||
current_image = make<GIFImageDescriptor>();
|
||||
|
|
Loading…
Reference in a new issue