[Refactor] (MG_Util, MG_Test): retire FastSTL for ska::flat_hash_map, the table MobileGlues settled on

This commit is contained in:
2026-08-12 00:11:54 -04:00
parent faa7b17da3
commit 21ec744ef2
6 changed files with 48 additions and 24 deletions
+16 -2
View File
@@ -55,9 +55,23 @@ namespace MobileGL {
using SizeT = std::size_t;
template <typename T, SizeT N>
using Array = std::array<T, N>;
// ska::flat_hash_map, the same table MobileGlues settled on, at the same commit.
//
// Open addressing with robin-hood probing, so a rehash moves the elements: any
// insert, emplace, operator[], reserve or rehash invalidates every iterator,
// reference and pointer into the map. Erase does too, and less obviously -
// deletion shifts the rest of the probe cluster backwards, so erasing one key
// can move a DIFFERENT key's element. Where a mapped value's address has to
// outlive later mutation, the map holds a UniquePtr/SharedPtr and the pointee
// stays put; those sites say so where they are declared.
//
// Its value_type is pair<Key, T> with the key exposed mutably, so `it->first =`
// compiles and silently corrupts the table - the one sharp edge this map has
// that a node-based one does not. Note the Allocator default matches that
// value_type: pair<Key, T>, not pair<const Key, T>.
template <typename Key, typename T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
using UnorderedMap = FastSTL::unordered_map<Key, T, Hash, KeyEqual, Allocator>;
class Allocator = std::allocator<std::pair<Key, T>>>
using UnorderedMap = ska::flat_hash_map<Key, T, Hash, KeyEqual, Allocator>;
template <typename T>
inline constexpr std::remove_reference_t<T>&& Move(T&& t) noexcept {
return static_cast<std::remove_reference_t<T>&&>(t);