Skip to content

Commit c7dd2ee

Browse files
ladisginmisonijnik
authored andcommitted
Remove unnecessary field from the ImmutableList
1 parent 96ed720 commit c7dd2ee

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

include/klee/ADT/ImmutableList.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,10 @@ template <typename T> class ImmutableList {
4747

4848
struct iterator {
4949
const ImmutableListNode *rootNode;
50-
std::unique_ptr<iterator> it;
5150
size_t get;
5251

5352
public:
54-
explicit iterator(const ImmutableListNode *p)
55-
: rootNode(p), it(nullptr), get(0) {
56-
if (rootNode && rootNode->prev.get()) {
57-
it = std::make_unique<iterator>(rootNode->prev.get());
58-
}
59-
}
53+
explicit iterator(const ImmutableListNode *p) : rootNode(p), get(0) {}
6054

6155
bool operator==(const iterator &b) const {
6256
return rootNode == b.rootNode && get == b.get;
@@ -66,17 +60,16 @@ template <typename T> class ImmutableList {
6660

6761
iterator &operator++() {
6862
++get;
69-
if (get < rootNode->prev_len) {
70-
it->operator++();
71-
}
7263
return *this;
7364
}
7465

7566
const T &operator*() const {
76-
if (get < rootNode->prev_len) {
77-
return **it;
67+
assert(get < rootNode->size() && "Out of bound");
68+
const ImmutableListNode *curNode = rootNode;
69+
while (get < curNode->prev_len) {
70+
curNode = curNode->prev.get();
7871
}
79-
return rootNode->values[get - rootNode->prev_len];
72+
return curNode->values[get - curNode->prev_len];
8073
}
8174

8275
const T &operator->() const { return **this; }

0 commit comments

Comments
 (0)