Преглед изворни кода

LibGfx/PortableFormat: Extract header reading in its own function

Lucas CHOLLET пре 2 година
родитељ
комит
f6ce06d56b
1 измењених фајлова са 12 додато и 5 уклоњено
  1. 12 5
      Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h

+ 12 - 5
Userland/Libraries/LibGfx/ImageFormats/PortableImageLoaderCommon.h

@@ -175,12 +175,9 @@ static ErrorOr<void> create_bitmap(TContext& context)
     return {};
     return {};
 }
 }
 
 
-template<typename TContext>
-static ErrorOr<void> decode(TContext& context)
+template<typename Context>
+static ErrorOr<void> read_header(Context& context)
 {
 {
-    if (context.state >= TContext::State::Decoded)
-        return {};
-
     TRY(read_magic_number(context));
     TRY(read_magic_number(context));
 
 
     TRY(read_whitespace(context));
     TRY(read_whitespace(context));
@@ -201,6 +198,16 @@ static ErrorOr<void> decode(TContext& context)
         TRY(read_whitespace(context));
         TRY(read_whitespace(context));
     }
     }
 
 
+    return {};
+}
+
+template<typename TContext>
+static ErrorOr<void> decode(TContext& context)
+{
+    if (context.state >= TContext::State::Decoded)
+        return {};
+
+    TRY(read_header(context));
     TRY(read_image_data(context));
     TRY(read_image_data(context));
 
 
     context.state = TContext::State::Decoded;
     context.state = TContext::State::Decoded;