You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
More efficient memory allocation for Strings and String Variants.
The vast majority of Strings are never modified so for most cases allocate memory for the string with the object. This results in one allocation in most cases instead of two. Use strNew() if strCat*() functions are needed. Update varNewStr() in the same way since String Variants can never be modified. This results in one allocation in all cases instead of three. Also update varNewStrZ() to use STR() instead of strNewZ() to save two more allocations.
This commit is contained in:
@ -172,7 +172,7 @@ cmdBegin(void)
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// Basic info on command start
|
||||
String *info = strNewFmt("%s command begin", strZ(cfgCommandRoleName()));
|
||||
String *info = strCatFmt(strNew(), "%s command begin", strZ(cfgCommandRoleName()));
|
||||
|
||||
// Free the old option string if it exists. This is needed when more than one command is run in a row so an option
|
||||
// string gets created for the new command.
|
||||
@ -213,7 +213,7 @@ cmdEnd(int code, const String *errorMessage)
|
||||
LOG_DETAIL_FMT("statistics: %s", strZ(jsonFromKv(statKv)));
|
||||
|
||||
// Basic info on command end
|
||||
String *info = strNewFmt("%s command end: ", strZ(cfgCommandRoleName()));
|
||||
String *info = strCatFmt(strNew(), "%s command end: ", strZ(cfgCommandRoleName()));
|
||||
|
||||
if (errorMessage == NULL)
|
||||
{
|
||||
|
Reference in New Issue
Block a user