1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-06-20 01:17:49 +02:00

Minor memory context optimization in restoreFile().

The temp mem context block was outside the if statement that determines if a file needs to be copied or not, which meant that some mem contexts would never be used.

Reverse this order to avoid creating unused mem contexts.
This commit is contained in:
David Steele
2026-02-07 17:01:32 +07:00
parent 06b99d93dc
commit 6079651443
+9 -8
View File
@@ -222,15 +222,16 @@ restoreFile(
for (unsigned int fileIdx = 0; fileIdx < lstSize(fileList); fileIdx++)
{
// Use a per-file mem context to reduce memory usage
MEM_CONTEXT_TEMP_BEGIN()
{
const RestoreFile *const file = lstGet(fileList, fileIdx);
RestoreFileResult *const fileResult = lstGet(result, fileIdx);
// Copy file from repository to database
RestoreFileResult *const fileResult = lstGet(result, fileIdx);
// Copy file from repository to database
if (fileResult->result == restoreResultCopy)
if (fileResult->result == restoreResultCopy)
{
// Use a per-file mem context to reduce memory usage
MEM_CONTEXT_TEMP_BEGIN()
{
const RestoreFile *const file = lstGet(fileList, fileIdx);
// If no repo file is currently open
if (repoFileLimit == 0)
{
@@ -414,8 +415,8 @@ restoreFile(
strZ(strNewEncode(encodingHex, checksum)), strZ(strNewEncode(encodingHex, file->checksum)));
}
}
MEM_CONTEXT_TEMP_END();
}
MEM_CONTEXT_TEMP_END();
}
}
MEM_CONTEXT_TEMP_END();