Change ValueId to just be an enum class, it does not need any operators

This commit is contained in:
Maxime Coste 2016-12-03 13:17:42 +00:00
parent 8a74ef9804
commit bc8c5522e2
4 changed files with 9 additions and 12 deletions

View File

@ -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);

View File

@ -181,7 +181,7 @@ static HighlighterAndId create_fill_highlighter(HighlighterParameters params)
template<typename T>
struct BufferSideCache
{
BufferSideCache() : m_id{ValueId::get_free_id()} {}
BufferSideCache() : m_id{get_free_value_id()} {}
T& get(const Buffer& buffer)
{

View File

@ -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});

View File

@ -68,16 +68,13 @@ private:
std::unique_ptr<Concept> m_value;
};
struct ValueId : public StronglyTypedNumber<ValueId, int>
{
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<ValueId, Value, MemoryDomain::Values>;