mirror of
https://github.com/Xahau/xahaud.git
synced 2026-09-27 15:38:01 +00:00
This commit makes several changes to the base_uint class, which was originally taken from Bitcoin and has already been heavily modified by Ripple engineers. It introduces conditional widening of the internal limb type, going from 32 to 64 bits if the requested number of bits is a multiple of 64. This change alone halves iteration counts for common operations and, combined with use of add-with-carry compiler intrinsics, helps leverage modern processor resources more effectively. Other changes include: - Extracting the arithmetic operations into free helper functions which operate on the limb array directly. - Replacing the SFINAE-based is_contiguous_container trait with a byte_copy_source concept. - Rewriting the hex parsing around a consteval lookup table and a simple left-to-right loop, replacing the old shift-based nibble accumulator. - Using memmove instead of memcpy when copying to avoid UB in the unlikely case where the source and destination buffers overlap. - Eliminating a workaround in operator<=> to handle MacOS quirks. - Removing redundant parseHex overloads and introducing from_hex as a factory function. - Introducing a tagless_compare() for cross-tag comparison. - Adding noexcept, [[nodiscard]], and constexpr throughout.
Basics
Utility functions and classes.
ripple/basic should contain no dependencies on other modules.
Choosing a rippled container.
-
std::vector- For ordered containers with most insertions or erases at the end.
-
std::deque- For ordered containers with most insertions or erases at the start or end.
-
std::list- For ordered containers with inserts and erases to the middle.
- For containers with iterators stable over insert and erase.
- Generally slower and bigger than
std::vectororstd::dequeexcept for those cases.
-
std::set- For sorted containers.
-
ripple::hash_set- Where inserts and contains need to be O(1).
- For "small" sets,
std::setmight be faster and smaller.
-
ripple::hardened_hash_set- For data sets where the key could be manipulated by an attacker in an attempt to mount an algorithmic complexity attack: see http://en.wikipedia.org/wiki/Algorithmic_complexity_attack
The following container is deprecated
std::unordered_set- Use
ripple::hash_setinstead, which uses a better hashing algorithm. - Or use
ripple::hardened_hash_setto prevent algorithmic complexity attacks.