mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Use cast to make for loop more readable in InfoPg module.
The previous way worked but was a head-scratcher when reading the code. This cast hopefully makes it a bit more obvious what is going on. Contributed by Cynthia Shang.
This commit is contained in:
parent
2514d08d0d
commit
f0417ee524
@ -112,7 +112,7 @@
|
||||
<release-item-contributor id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Info module improvements. Rename constants in <code>Info</code> module for consistency. Remove <code>#define</code> statements in the <code>InfoPg</code> module to conform with newly-adopted coding standards.</p>
|
||||
<p>Info module improvements. Rename constants in <code>Info</code> module for consistency. Remove <code>#define</code> statements in the <code>InfoPg</code> module to conform with newly-adopted coding standards. Use cast to make for loop more readable in <code>InfoPg</code> module.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
|
@ -88,8 +88,8 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type, Ciphe
|
||||
|
||||
// Iterate in reverse because we would like the most recent pg history to be in position 0. If we need to look at the
|
||||
// history list at all we'll be iterating from newest to oldest and putting newest in position 0 makes for more natural
|
||||
// looping.
|
||||
for (unsigned int pgHistoryIdx = strLstSize(pgHistoryKey) - 1; pgHistoryIdx < strLstSize(pgHistoryKey); pgHistoryIdx--)
|
||||
// looping. Cast the index check to an integer to test for >= 0 (for readability).
|
||||
for (unsigned int pgHistoryIdx = strLstSize(pgHistoryKey) - 1; (int)pgHistoryIdx >= 0; pgHistoryIdx--)
|
||||
{
|
||||
// Load JSON data into a KeyValue
|
||||
const KeyValue *pgDataKv = jsonToKv(
|
||||
@ -119,6 +119,7 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type, Ciphe
|
||||
else if (type != infoPgArchive)
|
||||
THROW_FMT(AssertError, "invalid InfoPg type %u", type);
|
||||
|
||||
// Using lstAdd because it is more efficient than lstInsert and loading this file is in critical code paths
|
||||
lstAdd(this->history, &infoPgData);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user