From bc8c5522e2e20a68a089265ee5794e7b0c4a93a3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 3 Dec 2016 13:17:42 +0000 Subject: [PATCH] Change ValueId to just be an enum class, it does not need any operators --- src/buffer_utils.cc | 2 +- src/highlighters.cc | 2 +- src/insert_completer.cc | 2 +- src/value.hh | 15 ++++++--------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 4ff1c1cf..e2a15252 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -89,7 +89,7 @@ void reload_file_buffer(Buffer& buffer) 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(); Buffer* buffer = buffer_manager.get_buffer_ifp(name); diff --git a/src/highlighters.cc b/src/highlighters.cc index ece03ca5..75398039 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -181,7 +181,7 @@ static HighlighterAndId create_fill_highlighter(HighlighterParameters params) template struct BufferSideCache { - BufferSideCache() : m_id{ValueId::get_free_id()} {} + BufferSideCache() : m_id{get_free_value_id()} {} T& get(const Buffer& buffer) { diff --git a/src/insert_completer.cc b/src/insert_completer.cc index ba06042d..e6e66c9a 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -67,7 +67,7 @@ namespace 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]; if (not cache_val) cache_val = Value(WordDB{buffer}); diff --git a/src/value.hh b/src/value.hh index eddd956e..cb47ad9b 100644 --- a/src/value.hh +++ b/src/value.hh @@ -68,16 +68,13 @@ private: std::unique_ptr m_value; }; -struct ValueId : public StronglyTypedNumber -{ - constexpr ValueId(int value = 0) : StronglyTypedNumber(value) {} +enum class ValueId : int {}; - static ValueId get_free_id() - { - static ValueId next; - return next++; - } -}; +inline ValueId get_free_value_id() +{ + static int next = 0; + return (ValueId)(next++); +} using ValueMap = UnorderedMap;