Merge pull request #6080 from YosysHQ/emil/hashlib-noexcept

hashlib: noexcept moves for performance
This commit is contained in:
Emil J 2026-08-05 07:33:15 +00:00 committed by GitHub
commit 7a2bd64c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -423,6 +423,7 @@ class HASHLIB_ATTRIBUTE_WARN_UNUSED dict {
std::vector<int> hashtable; std::vector<int> hashtable;
std::vector<entry_t> entries; std::vector<entry_t> entries;
OPS ops; OPS ops;
static_assert(std::is_nothrow_default_constructible_v<OPS>, "move ops are noexcept and default-construct OPS");
#ifdef NDEBUG #ifdef NDEBUG
static inline void do_assert(bool) { } static inline void do_assert(bool) { }
@ -641,7 +642,7 @@ public:
do_rehash(); do_rehash();
} }
dict(dict &&other) dict(dict &&other) noexcept
{ {
swap(other); swap(other);
} }
@ -652,7 +653,7 @@ public:
return *this; return *this;
} }
dict &operator=(dict &&other) { dict &operator=(dict &&other) noexcept {
clear(); clear();
swap(other); swap(other);
return *this; return *this;
@ -901,6 +902,7 @@ protected:
std::vector<int> hashtable; std::vector<int> hashtable;
std::vector<entry_t> entries; std::vector<entry_t> entries;
OPS ops; OPS ops;
static_assert(std::is_nothrow_default_constructible_v<OPS>, "move ops are noexcept and default-construct OPS");
#ifdef NDEBUG #ifdef NDEBUG
static inline void do_assert(bool) { } static inline void do_assert(bool) { }
@ -1091,7 +1093,7 @@ public:
do_rehash(); do_rehash();
} }
pool(pool &&other) pool(pool &&other) noexcept
{ {
swap(other); swap(other);
} }
@ -1102,7 +1104,7 @@ public:
return *this; return *this;
} }
pool &operator=(pool &&other) { pool &operator=(pool &&other) noexcept {
clear(); clear();
swap(other); swap(other);
return *this; return *this;