Skip to content

Commit

Permalink
Utf8StringBuilder.Append(char) -> Utf8StringBuilder.Append(byte)
Browse files Browse the repository at this point in the history
* Only ASCII constant chars we're passed to this method
  • Loading branch information
PaulusParssinen committed May 11, 2024
1 parent 77a600d commit 2e050a3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/coreclr/tools/Common/Internal/Text/Utf8StringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public Utf8StringBuilder Append(ReadOnlySpan<byte> value)
return this;
}

public Utf8StringBuilder Append(char value)
public Utf8StringBuilder Append(byte value)
{
Ensure(1);
if (value > 0x7F)
return Append(Encoding.UTF8.GetBytes(new char[] { value }));
_buffer[_length++] = (byte)value;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)

foreach (TypeDesc instArg in _details)
{
sb.Append('_');
sb.Append((byte)'_');
sb.Append(nameMangler.GetMangledTypeName(instArg));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)

for (int i = 0; i < _details.Variance.Length; i++)
{
sb.Append('_');
sb.Append((byte)'_');
sb.Append((checked((byte)_details.Variance[i])).ToStringInvariant());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)

if (_callSiteIdentifier != null)
{
sb.Append('_');
sb.Append((byte)'_');
_callSiteIdentifier.AppendMangledName(nameMangler, sb);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public int CompareTo(PInvokeModuleData other, CompilerComparer comparer)
public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
sb.Append(nameMangler.GetMangledTypeName(DeclaringModule.GetGlobalModuleType()));
sb.Append('_');
sb.Append((byte)'_');
sb.Append(nameMangler.SanitizeName(ModuleName));
if (DllImportSearchPath.HasValue)
{
sb.Append('_');
sb.Append((byte)'_');
sb.Append(((int)DllImportSearchPath.Value).ToString());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,26 @@ private void WriteCie(DwarfCie cie)

if (cie.FdesHaveAugmentationData)
{
augmentationString.Append('z');
augmentationString.Append((byte)'z');
}
if (cie.PersonalitySymbolName != null)
{
augmentationString.Append('P');
augmentationString.Append((byte)'P');
augmentationLength += 1u + AddressSize(cie.PersonalityEncoding);
}
if (cie.LsdaEncoding != 0)
{
augmentationString.Append('L');
augmentationString.Append((byte)'L');
augmentationLength++;
}
if (cie.PointerEncoding != 0)
{
augmentationString.Append('R');
augmentationString.Append((byte)'R');
augmentationLength++;
}
if (cie.IsSignalFrame)
{
augmentationString.Append('S');
augmentationString.Append((byte)'S');
}

uint length =
Expand Down

0 comments on commit 2e050a3

Please sign in to comment.