Skip to content

Commit fc8c282

Browse files
l0rincryanofsky
andcommitted
coins, refactor: Make AddFlags, SetDirty, SetFresh static
This makes the `Assume(&self.second == this)` check redundant Co-authored-by: Ryan Ofsky <[email protected]>
1 parent cd0498e commit fc8c282

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/coins.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,19 @@ struct CCoinsCacheEntry
162162
//! Adding a flag also requires a self reference to the pair that contains
163163
//! this entry in the CCoinsCache map and a reference to the sentinel of the
164164
//! flagged pair linked list.
165-
void AddFlags(uint8_t flags, CoinsCachePair& pair, CoinsCachePair& sentinel) noexcept
165+
static void AddFlags(uint8_t flags, CoinsCachePair& pair, CoinsCachePair& sentinel) noexcept
166166
{
167167
Assume(flags & (DIRTY | FRESH));
168-
Assume(&pair.second == this);
169-
if (!m_flags) {
170-
m_prev = sentinel.second.m_prev;
171-
m_next = &sentinel;
168+
if (!pair.second.m_flags) {
169+
pair.second.m_prev = sentinel.second.m_prev;
170+
pair.second.m_next = &sentinel;
172171
sentinel.second.m_prev = &pair;
173-
m_prev->second.m_next = &pair;
172+
pair.second.m_prev->second.m_next = &pair;
174173
}
175-
m_flags |= flags;
174+
pair.second.m_flags |= flags;
176175
}
177-
static void SetDirty(CoinsCachePair& pair, CoinsCachePair& sentinel) noexcept { pair.second.AddFlags(DIRTY, pair, sentinel); }
178-
static void SetFresh(CoinsCachePair& pair, CoinsCachePair& sentinel) noexcept { pair.second.AddFlags(FRESH, pair, sentinel); }
176+
static void SetDirty(CoinsCachePair& pair, CoinsCachePair& sentinel) noexcept { AddFlags(DIRTY, pair, sentinel); }
177+
static void SetFresh(CoinsCachePair& pair, CoinsCachePair& sentinel) noexcept { AddFlags(FRESH, pair, sentinel); }
179178

180179
void SetClean() noexcept
181180
{

0 commit comments

Comments
 (0)