Skip to content
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using Internal.Text;

namespace ILCompiler.ObjectWriter
{
internal class StringTableBuilder
{
private readonly MemoryStream _stream = new();
private readonly SortedSet<Utf8String> _reservedStrings = new();
private Dictionary<Utf8String, uint> _stringToOffset = new();
private readonly HashSet<Utf8String> _reservedStrings = new();
private readonly Dictionary<Utf8String, uint> _stringToOffset = new();

public void Write(Stream stream)
{
Expand All @@ -43,9 +42,18 @@ public void ReserveString(Utf8String text)

private void FlushReservedStrings()
{
Utf8String[] reservedStrings = _reservedStrings.ToArray();
if (_reservedStrings.Count == 0)
{
return;
}

Utf8String[] reservedStrings = new Utf8String[_reservedStrings.Count];
_reservedStrings.CopyTo(reservedStrings);

Comment thread
awakecoding marked this conversation as resolved.
// Establish a deterministic order before the in-place suffix sort.
Array.Sort(reservedStrings);

// Pre-sort the string based on their matching suffix
// Sort strings so matching suffixes are adjacent.
MultiKeySort(reservedStrings, 0);

// Add the strings to string table
Expand Down
Loading