1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:47:35 +00:00

LibCrypto: Make UnsignedBigInteger as fast as architecturally possible

This commit attempts to make UnsignedBigInteger as fast as possible
without changing the underlaying architecture.
This effort involves
- Preallocating space for vector operations
- Avoiding calls to computationally expensive functions
- Inlining or flattening functions (sensibly)
This commit is contained in:
AnotherTest 2020-04-29 22:35:54 +04:30 committed by Andreas Kling
parent 4d932ce701
commit c9321b4f00
2 changed files with 16 additions and 13 deletions

View file

@ -34,7 +34,7 @@
namespace Crypto {
struct UnsignedDivisionResult;
constexpr size_t STARTING_WORD_SIZE = 128;
constexpr size_t STARTING_WORD_SIZE = 512;
class UnsignedBigInteger {
public:
@ -86,8 +86,8 @@ public:
String to_base10() const;
private:
UnsignedBigInteger shift_left_by_n_words(const size_t number_of_words) const;
u32 shift_left_get_one_word(const size_t num_bits, const size_t result_word_index) const;
ALWAYS_INLINE UnsignedBigInteger shift_left_by_n_words(const size_t number_of_words) const;
ALWAYS_INLINE u32 shift_left_get_one_word(const size_t num_bits, const size_t result_word_index) const;
static constexpr size_t BITS_IN_WORD = 32;
AK::Vector<u32, STARTING_WORD_SIZE> m_words;