Skip to content

Commit

Permalink
Reuse new sting builder if it has bigger capacity than the cached one
Browse files Browse the repository at this point in the history
  • Loading branch information
TrayanZapryanov committed Mar 5, 2024
1 parent 0ad20e7 commit 596147e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion csharp/src/Google.Protobuf/JsonTokenizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ private static void Release(StringBuilder sb)
{
if (sb.Capacity <= MaxCachedStringBuilderSize)
{
cachedInstance = sb;
cachedInstance = cachedInstance?.Capacity >= sb.Capacity ? cachedInstance : sb;
}
}

Expand Down

0 comments on commit 596147e

Please sign in to comment.