From f6ce06d56bc9ca8b0d2c06dd5fc893b15efb8d76 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Mon, 10 Jul 2023 16:29:16 -0400 Subject: [PATCH] LibGfx/PortableFormat: Extract header reading in its own function --- .../ImageFormats/PortableImageLoaderCommon.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h b/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h index 34e5e8369f..0e675cd653 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h +++ b/Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h @@ -175,12 +175,9 @@ static ErrorOr create_bitmap(TContext& context) return {}; } -template -static ErrorOr decode(TContext& context) +template +static ErrorOr read_header(Context& context) { - if (context.state >= TContext::State::Decoded) - return {}; - TRY(read_magic_number(context)); TRY(read_whitespace(context)); @@ -201,6 +198,16 @@ static ErrorOr decode(TContext& context) TRY(read_whitespace(context)); } + return {}; +} + +template +static ErrorOr decode(TContext& context) +{ + if (context.state >= TContext::State::Decoded) + return {}; + + TRY(read_header(context)); TRY(read_image_data(context)); context.state = TContext::State::Decoded;