Change ValueId to just be an enum class, it does not need any operators
This commit is contained in:
parent
8a74ef9804
commit
bc8c5522e2
|
@ -89,7 +89,7 @@ void reload_file_buffer(Buffer& buffer)
|
||||||
|
|
||||||
Buffer* create_fifo_buffer(String name, int fd, bool scroll)
|
Buffer* create_fifo_buffer(String name, int fd, bool scroll)
|
||||||
{
|
{
|
||||||
static ValueId s_fifo_watcher_id = ValueId::get_free_id();
|
static ValueId s_fifo_watcher_id = get_free_value_id();
|
||||||
|
|
||||||
auto& buffer_manager = BufferManager::instance();
|
auto& buffer_manager = BufferManager::instance();
|
||||||
Buffer* buffer = buffer_manager.get_buffer_ifp(name);
|
Buffer* buffer = buffer_manager.get_buffer_ifp(name);
|
||||||
|
|
|
@ -181,7 +181,7 @@ static HighlighterAndId create_fill_highlighter(HighlighterParameters params)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct BufferSideCache
|
struct BufferSideCache
|
||||||
{
|
{
|
||||||
BufferSideCache() : m_id{ValueId::get_free_id()} {}
|
BufferSideCache() : m_id{get_free_value_id()} {}
|
||||||
|
|
||||||
T& get(const Buffer& buffer)
|
T& get(const Buffer& buffer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace
|
||||||
|
|
||||||
WordDB& get_word_db(const Buffer& buffer)
|
WordDB& get_word_db(const Buffer& buffer)
|
||||||
{
|
{
|
||||||
static const ValueId word_db_id = ValueId::get_free_id();
|
static const ValueId word_db_id = get_free_value_id();
|
||||||
Value& cache_val = buffer.values()[word_db_id];
|
Value& cache_val = buffer.values()[word_db_id];
|
||||||
if (not cache_val)
|
if (not cache_val)
|
||||||
cache_val = Value(WordDB{buffer});
|
cache_val = Value(WordDB{buffer});
|
||||||
|
|
15
src/value.hh
15
src/value.hh
|
@ -68,16 +68,13 @@ private:
|
||||||
std::unique_ptr<Concept> m_value;
|
std::unique_ptr<Concept> m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ValueId : public StronglyTypedNumber<ValueId, int>
|
enum class ValueId : int {};
|
||||||
{
|
|
||||||
constexpr ValueId(int value = 0) : StronglyTypedNumber(value) {}
|
|
||||||
|
|
||||||
static ValueId get_free_id()
|
inline ValueId get_free_value_id()
|
||||||
{
|
{
|
||||||
static ValueId next;
|
static int next = 0;
|
||||||
return next++;
|
return (ValueId)(next++);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
using ValueMap = UnorderedMap<ValueId, Value, MemoryDomain::Values>;
|
using ValueMap = UnorderedMap<ValueId, Value, MemoryDomain::Values>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user