You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Optimization for jsonFromStrInternal().
This is an extremely hot code path when saving the manifest so every little bit helps.
This commit is contained in:
		| @@ -69,6 +69,7 @@ | |||||||
|                         <commit subject="Simplify manifest defaults."/> |                         <commit subject="Simplify manifest defaults."/> | ||||||
|                         <commit subject="Convert varNewUInt64() to VARUINT64() where possible in manifest."/> |                         <commit subject="Convert varNewUInt64() to VARUINT64() where possible in manifest."/> | ||||||
|                         <commit subject="Pack manifest file structs to save memory."/> |                         <commit subject="Pack manifest file structs to save memory."/> | ||||||
|  |                         <commit subject="Optimization for jsonFromStrInternal()."/> | ||||||
|  |  | ||||||
|                         <release-item-contributor-list> |                         <release-item-contributor-list> | ||||||
|                             <release-item-contributor id="david.steele"/> |                             <release-item-contributor id="david.steele"/> | ||||||
|   | |||||||
| @@ -682,14 +682,13 @@ jsonFromStrInternal(String *json, const String *string) | |||||||
|         strCatChr(json, '"'); |         strCatChr(json, '"'); | ||||||
|  |  | ||||||
|         // Track portion of string with no escapes |         // Track portion of string with no escapes | ||||||
|  |         const char *stringPtr = strZ(string); | ||||||
|         const char *noEscape = NULL; |         const char *noEscape = NULL; | ||||||
|         size_t noEscapeSize = 0; |         size_t noEscapeSize = 0; | ||||||
|  |  | ||||||
|         for (unsigned int stringIdx = 0; stringIdx < strSize(string); stringIdx++) |         for (unsigned int stringIdx = 0; stringIdx < strSize(string); stringIdx++) | ||||||
|         { |         { | ||||||
|             char stringChr = strZ(string)[stringIdx]; |             switch (*stringPtr) | ||||||
|  |  | ||||||
|             switch (stringChr) |  | ||||||
|             { |             { | ||||||
|                 case '"': |                 case '"': | ||||||
|                 case '\\': |                 case '\\': | ||||||
| @@ -706,7 +705,7 @@ jsonFromStrInternal(String *json, const String *string) | |||||||
|                         noEscapeSize = 0; |                         noEscapeSize = 0; | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     switch (stringChr) |                     switch (*stringPtr) | ||||||
|                     { |                     { | ||||||
|                         case '"': |                         case '"': | ||||||
|                             strCatZ(json, "\\\""); |                             strCatZ(json, "\\\""); | ||||||
| @@ -744,12 +743,14 @@ jsonFromStrInternal(String *json, const String *string) | |||||||
|                 { |                 { | ||||||
|                     // If escape string is zero size then start it |                     // If escape string is zero size then start it | ||||||
|                     if (noEscapeSize == 0) |                     if (noEscapeSize == 0) | ||||||
|                         noEscape = strZ(string) + stringIdx; |                         noEscape = stringPtr; | ||||||
|  |  | ||||||
|                     noEscapeSize++; |                     noEscapeSize++; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             stringPtr++; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Copy portion of string without escapes |         // Copy portion of string without escapes | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user