Skip to content

Commit 04d1f4a

Browse files
committed
minor
1 parent 5538c3a commit 04d1f4a

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

include/phasar/Utils/StableVector.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,27 @@ class StableVector {
5151
using iterator_category = std::forward_iterator_tag;
5252

5353
Iterator &operator++() noexcept {
54-
if (++It != ItEnd) {
54+
if (LLVM_LIKELY(++It != ItEnd)) {
5555
return *this;
5656
}
5757

58-
if (++Outer == OuterEnd) {
58+
if (Outer == OuterEnd - 1) {
5959
// We are at the end of the tail loop
60+
It = nullptr;
6061
return *this;
6162
}
62-
if (Outer == OuterEnd - 1) {
63+
if (++Outer == OuterEnd - 1) {
6364
// We are at the end of the main loop => enter the tail loop now
6465
It = *Outer;
6566
ItEnd = Pos;
6667
return *this;
6768
}
6869
// We are still in the main loop
6970

70-
Cap = Total;
71-
Total <<= 1;
72-
7371
It = *Outer;
74-
ItEnd = It + Cap;
72+
ItEnd = It + Total;
73+
74+
Total <<= 1;
7575
return *this;
7676
}
7777

@@ -85,7 +85,7 @@ class StableVector {
8585
[[nodiscard]] pointer operator->() const noexcept { return It; }
8686

8787
[[nodiscard]] bool operator==(const Iterator &Other) const noexcept {
88-
return Outer == Other.Outer;
88+
return It == Other.It;
8989
}
9090

9191
[[nodiscard]] bool operator!=(const Iterator &Other) const noexcept {
@@ -96,8 +96,7 @@ class StableVector {
9696
template <bool C, typename = std::enable_if_t<!C && IsConst>>
9797
Iterator(const Iterator<C> &Other) noexcept
9898
: It(Other.It), ItEnd(Other.ItEnd), Outer(Other.Outer),
99-
OuterEnd(Other.OuterEnd), Cap(Other.Cap), Total(Other.Total),
100-
Pos(Other.Pos) {}
99+
OuterEnd(Other.OuterEnd), Total(Other.Total), Pos(Other.Pos) {}
101100

102101
~Iterator() = default;
103102

@@ -129,7 +128,6 @@ class StableVector {
129128
T *ItEnd = nullptr;
130129
T *const *Outer = nullptr;
131130
T *const *OuterEnd = nullptr;
132-
size_t Cap = InitialCapacity;
133131
size_t Total = InitialCapacity;
134132
T *Pos = nullptr;
135133
};

0 commit comments

Comments
 (0)