From 6bc3ed62669c686254fe9ebb52208421f3c3a617 Mon Sep 17 00:00:00 2001 From: Lenny Maiorani Date: Mon, 17 May 2021 09:08:40 -0600 Subject: [PATCH] LibCrypto: Change static constexpr array to function local constexpr Problem: - Static variables take memory and can be subject to less optimization (https://serenityos.godbolt.org/z/7EYebr1aa) - This static variable is only used in 1 place. Solution: - Move the variable into the function and make it non-static. --- Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h b/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h index 9222562e12..2b5e89c1a2 100644 --- a/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h +++ b/Userland/Libraries/LibCrypto/PK/Code/EMSA_PSS.h @@ -6,11 +6,10 @@ #pragma once +#include #include #include -static constexpr u8 zeros[] { 0, 0, 0, 0, 0, 0, 0, 0 }; - namespace Crypto { namespace PK { @@ -44,7 +43,9 @@ public: return; } - m_buffer.overwrite(0, zeros, 8); + constexpr Array zeros {}; + + m_buffer.overwrite(0, zeros.data(), 8); m_buffer.overwrite(8, message_hash.data, HashFunction::DigestSize); m_buffer.overwrite(8 + HashFunction::DigestSize, salt, SaltLength);