Skip to content

Commit

Permalink
rtlil: use said const iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer authored and povik committed Sep 2, 2024
1 parent 8d7cc41 commit 856f7b7
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions kernel/rtlil.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ struct RTLIL::Const
std::vector<RTLIL::State> 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 {
Expand Down Expand Up @@ -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) {}

Expand Down Expand Up @@ -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;
}
};
Expand Down

0 comments on commit 856f7b7

Please sign in to comment.