Skip to content

Commit b2edecd

Browse files
Use u8 literals in ManagedTextSection. (#86657)
1 parent 76e0313 commit b2edecd

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ public void WriteBytes(byte[] buffer, int start, int byteCount)
788788
WriteBytes(buffer.AsSpan(start, byteCount));
789789
}
790790

791-
private void WriteBytes(ReadOnlySpan<byte> buffer)
791+
internal void WriteBytes(ReadOnlySpan<byte> buffer)
792792
{
793793
if (!IsHead)
794794
{

src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/ManagedTextSection.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public ManagedTextSection(
9696

9797
public const int ManagedResourcesDataAlignment = 8;
9898

99-
private const string CorEntryPointDll = "mscoree.dll";
100-
private string CorEntryPointName => (ImageCharacteristics & Characteristics.Dll) != 0 ? "_CorDllMain" : "_CorExeMain";
99+
private static ReadOnlySpan<byte> CorEntryPointDll => "mscoree.dll"u8;
100+
private ReadOnlySpan<byte> CorEntryPointName => (ImageCharacteristics & Characteristics.Dll) != 0 ? "_CorDllMain"u8 : "_CorExeMain"u8;
101101

102102
private int SizeOfImportAddressTable => RequiresStartupStub ? (Is32Bit ? 2 * sizeof(uint) : 2 * sizeof(ulong)) : 0;
103103

@@ -365,11 +365,7 @@ private void WriteImportTable(BlobBuilder builder, int importTableRva, int impor
365365
// Hint table
366366
builder.WriteUInt16(0); // Hint 54|58
367367

368-
foreach (char ch in CorEntryPointName)
369-
{
370-
builder.WriteByte((byte)ch); // 65|69
371-
}
372-
368+
builder.WriteBytes(CorEntryPointName); // 65|69
373369
builder.WriteByte(0); // 66|70
374370
Debug.Assert(builder.Count - start == SizeOfImportTable);
375371
}
@@ -378,11 +374,7 @@ private static void WriteNameTable(BlobBuilder builder)
378374
{
379375
int start = builder.Count;
380376

381-
foreach (char ch in CorEntryPointDll)
382-
{
383-
builder.WriteByte((byte)ch);
384-
}
385-
377+
builder.WriteBytes(CorEntryPointDll);
386378
builder.WriteByte(0);
387379
builder.WriteUInt16(0);
388380
Debug.Assert(builder.Count - start == SizeOfNameTable);

0 commit comments

Comments
 (0)