Files

28 lines
1.1 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:56:38 -06:00
using System.Collections.Generic;
using Microsoft.CodeAnalysis.PooledObjects;
namespace Microsoft.CodeAnalysis.CSharp.Symbols;
internal static class SpecializedSymbolCollections
{
private static class PooledSymbolHashSet<TSymbol> where TSymbol : Symbol
{
internal static readonly ObjectPool<PooledHashSet<TSymbol>> s_poolInstance = PooledHashSet<TSymbol>.CreatePool((IEqualityComparer<TSymbol>)SymbolEqualityComparer.ConsiderEverything);
}
private static class PooledSymbolDictionary<TSymbol, V> where TSymbol : Symbol
{
internal static readonly ObjectPool<PooledDictionary<TSymbol, V>> s_poolInstance = PooledDictionary<TSymbol, V>.CreatePool((IEqualityComparer<TSymbol>)SymbolEqualityComparer.ConsiderEverything);
}
public static PooledHashSet<TSymbol> GetPooledSymbolHashSetInstance<TSymbol>() where TSymbol : Symbol
{
return PooledSymbolHashSet<TSymbol>.s_poolInstance.Allocate();
}
public static PooledDictionary<KSymbol, V> GetPooledSymbolDictionaryInstance<KSymbol, V>() where KSymbol : Symbol
{
return PooledSymbolDictionary<KSymbol, V>.s_poolInstance.Allocate();
}
}