aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/hashlib.h
diff options
context:
space:
mode:
authorAlberto Gonzalez <boqwxp@airmail.cc>2020-05-18 17:10:01 +0000
committerAlberto Gonzalez <boqwxp@airmail.cc>2020-05-19 23:32:53 +0000
commit6eea4b3d79590f874caa3ec740785781f3926666 (patch)
tree1a1fdff21a861283e0f184ae018ee37ad12432d4 /kernel/hashlib.h
parent976edb7597692ac04111b3c51b13e18105c14f42 (diff)
downloadyosys-6eea4b3d79590f874caa3ec740785781f3926666.tar.gz
yosys-6eea4b3d79590f874caa3ec740785781f3926666.tar.bz2
yosys-6eea4b3d79590f874caa3ec740785781f3926666.zip
kernel: Try an order-independent approach to hashing `dict`.
Co-Authored-By: David Shah <dave@ds0.me> Co-Authored-By: Eddie Hung <eddie@fpgeh.com>
Diffstat (limited to 'kernel/hashlib.h')
-rw-r--r--kernel/hashlib.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h
index 1284f3f8d..5c87b55f5 100644
--- a/kernel/hashlib.h
+++ b/kernel/hashlib.h
@@ -617,12 +617,10 @@ public:
}
unsigned int hash() const {
- std::vector<entry_t> entries_(entries); //make a copy to preserve const-ness
- std::sort(entries_.begin(), entries_.end());
unsigned int h = mkhash_init;
- for (unsigned int i = 0; i < entries_.size(); ++i) {
- h = mkhash(h, hash_ops<K>::hash(entries_[i].udata.first));
- h = mkhash(h, hash_ops<T>::hash(entries_[i].udata.second));
+ for (auto &entry : entries) {
+ h ^= hash_ops<K>::hash(entry.udata.first);
+ h ^= hash_ops<T>::hash(entry.udata.second);
}
return h;
}