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.
This commit is contained in:
Lenny Maiorani 2021-05-17 09:08:40 -06:00 committed by Linus Groh
parent 751ad19c86
commit 6bc3ed6266
Notes: sideshowbarker 2024-07-18 17:55:51 +09:00

View file

@ -6,11 +6,10 @@
#pragma once
#include <AK/Array.h>
#include <AK/Random.h>
#include <LibCrypto/PK/Code/Code.h>
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<u8, 8> 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);