From 856f7b7d2206aa662827f6bcd04bb7f8543f4508 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 23 Aug 2024 21:20:38 +0200 Subject: [PATCH] rtlil: use said const iterator --- kernel/rtlil.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 84952ce26dc..f8f87c9e25f 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -715,7 +715,7 @@ struct RTLIL::Const std::vector to_bits() const; std::string decode_string() const; - inline size_t size() const { + inline int size() const { if (is_str()) return 8 * str_.size(); else { @@ -783,11 +783,11 @@ struct RTLIL::Const size_t idx; public: - using iterator_category = std::random_access_iterator_tag; - using value_type = bool; + using iterator_category = std::input_iterator_tag; + using value_type = State; using difference_type = std::ptrdiff_t; - using pointer = const bool*; - using reference = bool; + using pointer = const State*; + using reference = State; const_iterator(const Const& c, size_t i) : parent(c), idx(i) {} @@ -893,15 +893,8 @@ struct RTLIL::Const inline unsigned int hash() const { unsigned int h = mkhash_init; - if(is_str()) { - // Copy to avoid unpacking `this` - Const c = Const(*this); - for (auto b : c.bits()) - h = mkhash(h, b); - } else { - for (auto b : get_bits()) - h = mkhash(h, b); - } + for (State b : bits()) + h = mkhash(h, b); return h; } };