operand: Implement operand hashing and use hashed set for declarations

Instead of manually searching each element in the declarations vector,
use an unordered_set to emplace new declarations avoiding repetition.
This commit is contained in:
ReinUsesLisp
2019-06-08 05:23:15 -03:00
parent f7c4b07a7e
commit 1e665afa36
10 changed files with 66 additions and 13 deletions

View File

@@ -6,6 +6,7 @@
#pragma once
#include <cstddef>
#include <cstring>
#include <typeindex>
#include "operand.h"
@@ -23,6 +24,8 @@ public:
bool operator==(const Operand& other) const override;
std::size_t Hash() const override;
template <typename T>
static LiteralNumber* Create(T value) {
static_assert(sizeof(T) == 4 || sizeof(T) == 8);