diff options
author | Nico Weber <thakis@chromium.org> | 2023-01-06 12:05:53 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-06 19:17:22 +0100 |
commit | 090bd02a8885fbdb2b510ffd23cef3e2e31cf6ef (patch) | |
tree | a311109e7c0a8e84318b2a076e90a6a751f61c8f | |
parent | aa107ef2d68226ed459225e83d4539de263292fd (diff) | |
download | serenity-090bd02a8885fbdb2b510ffd23cef3e2e31cf6ef.zip |
LibGfx: Extract all_bytes_are_zero() function in ICCProfile
-rw-r--r-- | Userland/Libraries/LibGfx/ICCProfile.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGfx/ICCProfile.cpp b/Userland/Libraries/LibGfx/ICCProfile.cpp index 19f0f60f7e..406a320387 100644 --- a/Userland/Libraries/LibGfx/ICCProfile.cpp +++ b/Userland/Libraries/LibGfx/ICCProfile.cpp @@ -234,15 +234,21 @@ ErrorOr<XYZ> parse_pcs_illuminant(ICCHeader const& header) return xyz; } +template<size_t N> +bool all_bytes_are_zero(const u8 (&bytes)[N]) +{ + for (u8 byte : bytes) { + if (byte != 0) + return false; + } + return true; +} + Optional<Crypto::Hash::MD5::DigestType> parse_profile_id(ICCHeader const& header) { // ICC v4, 7.2.18 Profile ID field // "A profile ID field value of zero (00h) shall indicate that a profile ID has not been calculated." - bool did_calculate_profile_id = false; - for (u8 b : header.profile_id) - if (b != 0) - did_calculate_profile_id = true; - if (!did_calculate_profile_id) + if (all_bytes_are_zero(header.profile_id)) return {}; Crypto::Hash::MD5::DigestType md5; |