Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't have struct local in ValueStringBuilder due to hitting JIT opti…
…mization limits

Cf. #67448 (comment)
  • Loading branch information
gfoidl committed Apr 4, 2022
commit da31c0b334046205da7aa776dceaecc2c82e56ba
10 changes: 4 additions & 6 deletions src/libraries/Common/src/System/Text/ValueStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ public void Insert(int index, string? s)
public void Append(char c)
{
int pos = _pos;
Span<char> chars = _chars;
if ((uint)pos < (uint)chars.Length)
if ((uint)pos < (uint)_chars.Length)
{
chars[pos] = c;
_chars[pos] = c;
_pos = pos + 1;
}
else
Expand All @@ -191,10 +190,9 @@ public void Append(string? s)
}

int pos = _pos;
Span<char> chars = _chars;
if (s.Length == 1 && (uint)pos < (uint)chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc.
if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc.
{
chars[pos] = s[0];
_chars[pos] = s[0];
_pos = pos + 1;
}
else
Expand Down