diff --git a/src/interned_string.cc b/src/interned_string.cc index fb6898c0..0755e3d4 100644 --- a/src/interned_string.cc +++ b/src/interned_string.cc @@ -28,7 +28,7 @@ InternedString StringRegistry::acquire(StringView str) auto it = m_slot_map.find(str); if (it == m_slot_map.end()) { - size_t slot; + Slot slot; if (not m_free_slots.empty()) { slot = m_free_slots.back(); @@ -48,20 +48,20 @@ InternedString StringRegistry::acquire(StringView str) return InternedString{storage_view, slot}; } - size_t slot = it->second; + Slot slot = it->second; auto& data = m_storage[slot]; ++data.refcount; return {{data.data.data(), (int)data.data.size()}, slot}; } -void StringRegistry::acquire(size_t slot) +void StringRegistry::acquire(Slot slot) { kak_assert(slot < m_storage.size()); kak_assert(m_storage[slot].refcount > 0); ++m_storage[slot].refcount; } -void StringRegistry::release(size_t slot) noexcept +void StringRegistry::release(Slot slot) noexcept { kak_assert(m_storage[slot].refcount > 0); if (--m_storage[slot].refcount == 0) diff --git a/src/interned_string.hh b/src/interned_string.hh index 66c7bd58..b74653b7 100644 --- a/src/interned_string.hh +++ b/src/interned_string.hh @@ -6,6 +6,8 @@ #include "unordered_map.hh" #include "vector.hh" +#include + namespace Kakoune { @@ -17,13 +19,14 @@ public: void debug_stats() const; private: friend class InternedString; + using Slot = uint32_t; InternedString acquire(StringView str); - void acquire(size_t slot); - void release(size_t slot) noexcept; + void acquire(Slot slot); + void release(Slot slot) noexcept; - UnorderedMap m_slot_map; - Vector m_free_slots; + UnorderedMap m_slot_map; + Vector m_free_slots; struct DataAndRefCount { Vector data; @@ -101,7 +104,7 @@ public: private: friend class StringRegistry; - InternedString(StringView str, size_t slot) + InternedString(StringView str, StringRegistry::Slot slot) : StringView(str), m_slot(slot) {} void acquire_ifn(StringView str) @@ -121,7 +124,7 @@ private: StringRegistry::instance().release(m_slot); } - size_t m_slot = -1; + StringRegistry::Slot m_slot = -1; }; inline size_t hash_value(const Kakoune::InternedString& str)