extract duplicated AOF list formatting logic into helper function (#14012)
CI / test-ubuntu-latest (push) Waiting to run Details
CI / test-sanitizer-address (push) Waiting to run Details
CI / build-debian-old (push) Waiting to run Details
CI / build-macos-latest (push) Waiting to run Details
CI / build-32bit (push) Waiting to run Details
CI / build-libc-malloc (push) Waiting to run Details
CI / build-centos-jemalloc (push) Waiting to run Details
CI / build-old-chain-jemalloc (push) Waiting to run Details
Codecov / code-coverage (push) Waiting to run Details
External Server Tests / test-external-standalone (push) Waiting to run Details
External Server Tests / test-external-cluster (push) Waiting to run Details
External Server Tests / test-external-nodebug (push) Waiting to run Details
Spellcheck / Spellcheck (push) Waiting to run Details

Separated the repeated logic for iterating and formatting AOF info from
both
history and incremental AOF lists into a new helper function named 
appendAofInfoFromList. This improves code readability, reduces
duplication,
and makes the getAofManifestAsString function cleaner and easier to
maintain.

No changes in behavior were introduced.
This commit is contained in:
Hyeon Sung 2025-05-20 12:08:03 +09:00 committed by GitHub
parent 51ad2f8d00
commit 9a9aa921bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 12 deletions

View File

@ -179,6 +179,19 @@ sds getTempAofManifestFileName(void) {
server.aof_filename, MANIFEST_NAME_SUFFIX);
}
sds appendAofInfoFromList(sds buf, list *aofList) {
listNode *ln;
listIter li;
listRewind(aofList, &li);
while ((ln = listNext(&li)) != NULL) {
aofInfo *ai = (aofInfo*)ln->value;
buf = aofInfoFormat(buf, ai);
}
return buf;
}
/* Returns the string representation of aofManifest pointed to by am.
*
* The string is multiple lines separated by '\n', and each line represents
@ -198,8 +211,6 @@ sds getAofManifestAsString(aofManifest *am) {
serverAssert(am != NULL);
sds buf = sdsempty();
listNode *ln;
listIter li;
/* 1. Add BASE File information, it is always at the beginning
* of the manifest file. */
@ -208,18 +219,10 @@ sds getAofManifestAsString(aofManifest *am) {
}
/* 2. Add HISTORY type AOF information. */
listRewind(am->history_aof_list, &li);
while ((ln = listNext(&li)) != NULL) {
aofInfo *ai = (aofInfo*)ln->value;
buf = aofInfoFormat(buf, ai);
}
buf = appendAofInfoFromList(buf, am->history_aof_list);
/* 3. Add INCR type AOF information. */
listRewind(am->incr_aof_list, &li);
while ((ln = listNext(&li)) != NULL) {
aofInfo *ai = (aofInfo*)ln->value;
buf = aofInfoFormat(buf, ai);
}
buf = appendAofInfoFromList(buf, am->incr_aof_list);
return buf;
}