mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-11 20:21:26 +00:00
hashlib: don't build an unused hash for expired value in do_insert
This commit is contained in:
parent
cec48c6abd
commit
ccf140f2ef
1 changed files with 3 additions and 7 deletions
|
@ -509,12 +509,11 @@ class dict {
|
|||
return do_lookup_internal(key, hash);
|
||||
}
|
||||
|
||||
int do_insert(const K &key, Hasher::hash_t &hash)
|
||||
int do_insert(const K &key, const Hasher::hash_t &hash)
|
||||
{
|
||||
if (hashtable.empty()) {
|
||||
entries.emplace_back(std::pair<K, T>(key, T()), -1);
|
||||
do_rehash();
|
||||
hash = do_hash(key);
|
||||
} else {
|
||||
entries.emplace_back(std::pair<K, T>(key, T()), hashtable[hash]);
|
||||
hashtable[hash] = entries.size() - 1;
|
||||
|
@ -522,12 +521,11 @@ class dict {
|
|||
return entries.size() - 1;
|
||||
}
|
||||
|
||||
int do_insert(const std::pair<K, T> &value, Hasher::hash_t &hash)
|
||||
int do_insert(const std::pair<K, T> &value, const Hasher::hash_t &hash)
|
||||
{
|
||||
if (hashtable.empty()) {
|
||||
entries.emplace_back(value, -1);
|
||||
do_rehash();
|
||||
hash = do_hash(value.first);
|
||||
} else {
|
||||
entries.emplace_back(value, hashtable[hash]);
|
||||
hashtable[hash] = entries.size() - 1;
|
||||
|
@ -535,13 +533,11 @@ class dict {
|
|||
return entries.size() - 1;
|
||||
}
|
||||
|
||||
int do_insert(std::pair<K, T> &&rvalue, Hasher::hash_t &hash)
|
||||
int do_insert(std::pair<K, T> &&rvalue, const Hasher::hash_t &hash)
|
||||
{
|
||||
if (hashtable.empty()) {
|
||||
auto key = rvalue.first;
|
||||
entries.emplace_back(std::forward<std::pair<K, T>>(rvalue), -1);
|
||||
do_rehash();
|
||||
hash = do_hash(key);
|
||||
} else {
|
||||
entries.emplace_back(std::forward<std::pair<K, T>>(rvalue), hashtable[hash]);
|
||||
hashtable[hash] = entries.size() - 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue