diff --git a/kernel/hashlib.h b/kernel/hashlib.h index b43b7302e..9c53e6687 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -179,58 +179,58 @@ struct hash_ops { }; template struct hash_ops> { - static inline bool cmp(std::pair a, std::pair b) { + static inline bool cmp(const std::pair &a, const std::pair &b) { return a == b; } - [[nodiscard]] static inline Hasher hash_into(std::pair a, Hasher h) { + [[nodiscard]] static inline Hasher hash_into(const std::pair &a, Hasher h) { h = hash_ops

::hash_into(a.first, h); h = hash_ops::hash_into(a.second, h); return h; } - HASH_TOP_LOOP_FST (std::pair a) HASH_TOP_LOOP_SND + HASH_TOP_LOOP_FST (const std::pair &a) HASH_TOP_LOOP_SND }; template struct hash_ops> { - static inline bool cmp(std::tuple a, std::tuple b) { + static inline bool cmp(const std::tuple &a, const std::tuple &b) { return a == b; } template - static inline typename std::enable_if::type hash_into(std::tuple, Hasher h) { + static inline typename std::enable_if::type hash_into(const std::tuple &, Hasher h) { return h; } template - static inline typename std::enable_if::type hash_into(std::tuple a, Hasher h) { + static inline typename std::enable_if::type hash_into(const std::tuple &a, Hasher h) { typedef hash_ops>::type> element_ops_t; h = hash_into(a, h); h = element_ops_t::hash_into(std::get(a), h); return h; } - HASH_TOP_LOOP_FST (std::tuple a) HASH_TOP_LOOP_SND + HASH_TOP_LOOP_FST (const std::tuple &a) HASH_TOP_LOOP_SND }; template struct hash_ops> { - static inline bool cmp(std::vector a, std::vector b) { + static inline bool cmp(const std::vector &a, const std::vector &b) { return a == b; } - [[nodiscard]] static inline Hasher hash_into(std::vector a, Hasher h) { + [[nodiscard]] static inline Hasher hash_into(const std::vector &a, Hasher h) { h.eat((uint32_t)a.size()); for (auto k : a) h.eat(k); return h; } - HASH_TOP_LOOP_FST (std::vector a) HASH_TOP_LOOP_SND + HASH_TOP_LOOP_FST (const std::vector &a) HASH_TOP_LOOP_SND }; template struct hash_ops> { - static inline bool cmp(std::array a, std::array b) { + static inline bool cmp(const std::array &a, const std::array &b) { return a == b; } - [[nodiscard]] static inline Hasher hash_into(std::array a, Hasher h) { + [[nodiscard]] static inline Hasher hash_into(const std::array &a, Hasher h) { for (const auto& k : a) h = hash_ops::hash_into(k, h); return h; } - HASH_TOP_LOOP_FST (std::array a) HASH_TOP_LOOP_SND + HASH_TOP_LOOP_FST (const std::array &a) HASH_TOP_LOOP_SND }; struct hash_cstr_ops { @@ -302,10 +302,10 @@ template<> struct hash_ops { }; template struct hash_ops> { - static inline bool cmp(std::variant a, std::variant b) { + static inline bool cmp(const std::variant &a, const std::variant &b) { return a == b; } - [[nodiscard]] static inline Hasher hash_into(std::variant a, Hasher h) { + [[nodiscard]] static inline Hasher hash_into(const std::variant &a, Hasher h) { std::visit([& h](const auto &v) { h.eat(v); }, a); h.eat(a.index()); return h; @@ -313,10 +313,10 @@ template struct hash_ops> { }; template struct hash_ops> { - static inline bool cmp(std::optional a, std::optional b) { + static inline bool cmp(const std::optional &a, const std::optional &b) { return a == b; } - [[nodiscard]] static inline Hasher hash_into(std::optional a, Hasher h) { + [[nodiscard]] static inline Hasher hash_into(const std::optional &a, Hasher h) { if(a.has_value()) h.eat(*a); else