Skip to content

Commit

Permalink
Couple of uses of a PooledHashSet(Of Symbol) (#48978)
Browse files Browse the repository at this point in the history
Make use of `PooledHashSet` rather that creating a new instance each time.
  • Loading branch information
AdamSpeight2008 authored Nov 12, 2020
1 parent a351a14 commit dff9639
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ _Default:
results As ArrayBuilder(Of Symbol))
Debug.Assert(results IsNot Nothing)

Dim uniqueSymbols = New HashSet(Of Symbol)()
Dim uniqueSymbols = PooledHashSet(Of Symbol).GetInstance()
Dim tempResults = ArrayBuilder(Of Symbol).GetInstance(arities.Count)

For Each knownArity In arities
Expand All @@ -1949,6 +1949,7 @@ _Default:
tempResults.Free()

results.AddRange(uniqueSymbols)
uniqueSymbols.Free()
End Sub

Private Shadows Sub LookupSymbols(binder As Binder,
Expand Down Expand Up @@ -1981,15 +1982,15 @@ _Default:
If result.HasDiagnostic Then
' In the ambiguous symbol case, we have a good symbol with a diagnostics that
' mentions the other symbols. Union everything together with a set to prevent dups.
Dim symbolSet As New HashSet(Of Symbol)
Dim symbolSet = PooledHashSet(Of Symbol).GetInstance()
Dim symBuilder = ArrayBuilder(Of Symbol).GetInstance()
AddSymbolsFromDiagnosticInfo(symBuilder, result.Diagnostic)
symbolSet.UnionWith(symBuilder)
symbolSet.UnionWith(result.Symbols)
symBuilder.Free()

results.AddRange(symbolSet)

symbolSet.Free()
ElseIf result.HasSingleSymbol AndAlso result.SingleSymbol.Kind = SymbolKind.Namespace AndAlso
DirectCast(result.SingleSymbol, NamespaceSymbol).NamespaceKind = NamespaceKindNamespaceGroup Then
results.AddRange(DirectCast(result.SingleSymbol, NamespaceSymbol).ConstituentNamespaces)
Expand Down

0 comments on commit dff9639

Please sign in to comment.