Skip to content
Merged
Show file tree
Hide file tree
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 @@ -39,11 +39,11 @@ public static void Replace(StringBuilder builder, List<Pair> paths)

var matches = FindMatches(builder, paths);

// Sort by position descending
var orderByDescending = matches.OrderByDescending(_ => _.Index);
// Sort by position descending. In-place to avoid LINQ allocation
matches.Sort((a, b) => b.Index.CompareTo(a.Index));

// Apply matches
foreach (var match in orderByDescending)
foreach (var match in matches)
{
builder.Overwrite(match.Value, match.Index, match.Length);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Verify/Serialization/Scrubbers/GuidScrubber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public static void ReplaceGuids(StringBuilder builder, Counter counter)

var matches = FindMatches(builder, counter);

// Sort by position descending
var orderByDescending = matches.OrderByDescending(_ => _.Index);
// Sort by position descending. In-place to avoid LINQ allocation
matches.Sort((a, b) => b.Index.CompareTo(a.Index));

// Apply matches
foreach (var match in orderByDescending)
foreach (var match in matches)
{
builder.Overwrite(match.Value, match.Index, 36);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public static void PerformReplacements(StringBuilder builder, string find, strin

var matches = FindMatches(builder, find);

// Sort by position descending
var orderByDescending = matches.OrderByDescending(_ => _);
// Sort by position descending. In-place to avoid LINQ allocation
matches.Sort((a, b) => b.CompareTo(a));

// Apply matches
foreach (var match in orderByDescending)
foreach (var match in matches)
{
builder.Overwrite(replace, match, find.Length);
}
Expand Down
Loading