Skip to content

Commit dd0740e

Browse files
Use pooled collections in a couple of places
1 parent 1250e38 commit dd0740e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/src/DefaultRazorIntermediateNodeLoweringPhase.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ protected override void ExecuteCore(RazorCodeDocument codeDocument)
8383
// 1. Prioritize non-imported usings over imported ones.
8484
// 2. Don't import usings that already exist in primary document.
8585
// 3. Allow duplicate usings in primary document (C# warning).
86-
var usingReferences = new List<UsingReference>(visitor.Usings);
86+
using var _ = ListPool<UsingReference>.GetPooledObject(out var usingReferences);
87+
usingReferences.AddRange(visitor.Usings);
88+
8789
for (var j = importedUsings.Count - 1; j >= 0; j--)
8890
{
8991
var importedUsing = importedUsings[j];
@@ -180,10 +182,10 @@ private static IReadOnlyList<UsingReference> ImportDirectives(
180182
return importsVisitor.Usings;
181183
}
182184

183-
private void PostProcessImportedDirectives(DocumentIntermediateNode document)
185+
private static void PostProcessImportedDirectives(DocumentIntermediateNode document)
184186
{
185187
var directives = document.FindDescendantReferences<DirectiveIntermediateNode>();
186-
var seenDirectives = new HashSet<DirectiveDescriptor>();
188+
using var _ = HashSetPool<DirectiveDescriptor>.GetPooledObject(out var seenDirectives);
187189
for (var i = directives.Count - 1; i >= 0; i--)
188190
{
189191
var reference = directives[i];

0 commit comments

Comments
 (0)