mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-03 01:40:23 +00:00
Use unordered_map instead of dict for IdString char* to index storage.
dict is pretty slow when you don't ever need to iterate the container in order. And the hashfunction for char* in dict hashes for every single byte in the string, likely doing significantly more work than std::hash.
This commit is contained in:
parent
8f6d7a3043
commit
2c8b4d7ad1
2 changed files with 5 additions and 2 deletions
|
@ -35,7 +35,7 @@ YOSYS_NAMESPACE_BEGIN
|
|||
bool RTLIL::IdString::destruct_guard_ok = false;
|
||||
RTLIL::IdString::destruct_guard_t RTLIL::IdString::destruct_guard;
|
||||
std::vector<char*> RTLIL::IdString::global_id_storage_;
|
||||
dict<char*, int> RTLIL::IdString::global_id_index_;
|
||||
std::unordered_map<std::string_view, int> RTLIL::IdString::global_id_index_;
|
||||
#ifndef YOSYS_NO_IDS_REFCNT
|
||||
std::vector<int> RTLIL::IdString::global_refcount_storage_;
|
||||
std::vector<int> RTLIL::IdString::global_free_idx_list_;
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
#include "kernel/yosys_common.h"
|
||||
#include "kernel/yosys.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
namespace RTLIL
|
||||
|
@ -122,7 +125,7 @@ struct RTLIL::IdString
|
|||
} destruct_guard;
|
||||
|
||||
static std::vector<char*> global_id_storage_;
|
||||
static dict<char*, int> global_id_index_;
|
||||
static std::unordered_map<std::string_view, int> global_id_index_;
|
||||
#ifndef YOSYS_NO_IDS_REFCNT
|
||||
static std::vector<int> global_refcount_storage_;
|
||||
static std::vector<int> global_free_idx_list_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue