Skip to content

Commit d5ebaf2

Browse files
committed
Reduce allocations in SymbolKey.CreateResolution
Related to https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2136177
1 parent 67cf09a commit d5ebaf2

File tree

1 file changed

+2
-1
lines changed
  • src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey

1 file changed

+2
-1
lines changed

src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/SymbolKey/SymbolKey.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ public readonly SymbolKeyResolution Resolve(
235235
public override readonly string ToString()
236236
=> _symbolKeyData;
237237

238+
// Note: this method may clear 'symbols' before returning.
238239
private static SymbolKeyResolution CreateResolution<TSymbol>(
239240
PooledArrayBuilder<TSymbol> symbols, string reasonIfFailed, out string? failureReason)
240241
where TSymbol : class, ISymbol
@@ -253,7 +254,7 @@ private static SymbolKeyResolution CreateResolution<TSymbol>(
253254
{
254255
failureReason = null;
255256
return new SymbolKeyResolution(
256-
ImmutableArray<ISymbol>.CastUp(symbols.Builder.ToImmutable()),
257+
ImmutableArray<ISymbol>.CastUp(symbols.Builder.ToImmutableAndClear()),
257258
CandidateReason.Ambiguous);
258259
}
259260
}

0 commit comments

Comments
 (0)