1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibGfx/PNG: Don't use a loop to read chunks in decode_png_ihdr()

This chunk is the first one, so we can remove that loop.
This commit is contained in:
Lucas CHOLLET 2023-07-17 00:18:42 -04:00 committed by Sam Atkins
parent ff6d82c3e7
commit 8d907b6535

View file

@ -614,14 +614,15 @@ static ErrorOr<void> decode_png_ihdr(PNGLoadingContext& context)
size_t data_remaining = context.data_size - (context.data_current_ptr - context.data);
Streamer streamer(context.data_current_ptr, data_remaining);
while (!streamer.at_end() && !context.has_seen_iend) {
TRY(process_chunk(streamer, context));
context.data_current_ptr = streamer.current_data_ptr();
// https://www.w3.org/TR/png/#11IHDR
// The IHDR chunk shall be the first chunk in the PNG datastream.
TRY(process_chunk(streamer, context));
if (context.state == PNGLoadingContext::State::IHDRDecoded)
return {};
}
context.data_current_ptr = streamer.current_data_ptr();
VERIFY(context.state == PNGLoadingContext::State::IHDRDecoded);
return {};
}
static bool decode_png_image_data_chunk(PNGLoadingContext& context)