mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-08-28 17:14:11 +02:00
hashlib: allow forcing Hasher state, use it for IdString trivial hashing
This commit is contained in:
@@ -132,6 +132,13 @@ class Hasher {
|
||||
state ^= t;
|
||||
}
|
||||
|
||||
void force(hash_t new_state) {
|
||||
state = new_state;
|
||||
}
|
||||
|
||||
bool is_new() const {
|
||||
return state == Hasher().state;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -361,6 +361,12 @@ namespace RTLIL
|
||||
}
|
||||
|
||||
Hasher hash_acc(Hasher h) const {
|
||||
// If we're starting a hashing sequence, simply start with unhashed ID
|
||||
if (h.is_new()) {
|
||||
h.force((Hasher::hash_t) index_);
|
||||
return h;
|
||||
}
|
||||
|
||||
return hash_ops<int>::hash_acc(index_, h);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user