Eliminate code duplication and improve documentation:

The legacy functions `cdirFirst` and `dirFirst` were mostly
identical; the differences were only type-related. The same
situation existed with `cdirNext` and `dirNext`.

This commit removes the duplicated code by introducing new
template functions that abstract away the differences that
are present between each pair of functions.

This commit also improves the naming of function arguments,
helping to elucidate their purpose & use and to make the
code self-documenting.
This commit is contained in:
Nik Bougalis
2021-09-03 03:58:45 -07:00
parent c231adf324
commit 234b754038
7 changed files with 187 additions and 186 deletions

View File

@@ -3410,13 +3410,7 @@ NetworkOPsImp::getBookPage(
uTipIndex = sleOfferDir->key();
saDirRate = amountFromQuality(getQuality(uTipIndex));
cdirFirst(
view,
uTipIndex,
sleOfferDir,
uBookEntry,
offerIndex,
viewJ);
cdirFirst(view, uTipIndex, sleOfferDir, uBookEntry, offerIndex);
JLOG(m_journal.trace())
<< "getBookPage: uTipIndex=" << uTipIndex;
@@ -3536,13 +3530,7 @@ NetworkOPsImp::getBookPage(
JLOG(m_journal.warn()) << "Missing offer";
}
if (!cdirNext(
view,
uTipIndex,
sleOfferDir,
uBookEntry,
offerIndex,
viewJ))
if (!cdirNext(view, uTipIndex, sleOfferDir, uBookEntry, offerIndex))
{
bDirectAdvance = true;
}