29 instantiations of ObjectPool
Microsoft.CodeAnalysis.CodeStyle (29)
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (4)
43
private static readonly ObjectPool<ConcurrentStack<AnalysisResult>> s_analysisResultPool =
new
(() => new());
44
private static readonly ObjectPool<ConcurrentSet<SyntaxNode>> s_nodeSetPool =
new
(() => []);
46
private static readonly ObjectPool<ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>>> s_fieldToUsageLocationPool =
new
(() => []);
60
_fieldNamesPool =
new
(() => new(this.SyntaxFacts.StringComparer));
src\Compilers\Core\Portable\Collections\OrderPreservingMultiDictionary.cs (1)
60
var pool = new
ObjectPool
<OrderPreservingMultiDictionary<K, V>>(
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (1)
94
var pool = new
ObjectPool
<StringTable>(pool => new StringTable(pool), Environment.ProcessorCount * 2);
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
495
pool = new
ObjectPool
<ArrayBuilder<T>>(() => new ArrayBuilder<T>(pool!), size);
src\Dependencies\PooledObjects\PooledDelegates.cs (1)
19
public static readonly ObjectPool<T> Instance =
new
(() => new T(), 20);
src\Dependencies\PooledObjects\PooledDictionary.cs (1)
46
pool = new
ObjectPool
<PooledDictionary<K, V>>(() => new PooledDictionary<K, V>(pool!, keyComparer), 128);
src\Dependencies\PooledObjects\PooledHashSet.cs (1)
35
pool = new
ObjectPool
<PooledHashSet<T>>(() => new PooledHashSet<T>(pool!, equalityComparer), 128);
src\Dependencies\PooledObjects\PooledStringBuilder.cs (1)
84
pool = new
ObjectPool
<PooledStringBuilder>(() => new PooledStringBuilder(pool!), size);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\IntervalTreeHelpers.cs (1)
37
private static readonly ObjectPool<Stack<TNode>> s_nodeStackPool =
new
(() => new(), 128, trimOnFree: false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
852
private static readonly ObjectPool<Stack<TDirectiveTriviaSyntax>> s_stackPool =
new
(() => new());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.BasicBlockAnalysisData.cs (1)
24
new
(() => new BasicBlockAnalysisData());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (1)
32
private static readonly ObjectPool<Walker> s_visitorPool =
new
(() => new Walker());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormatEngine.cs (1)
36
private static readonly ObjectPool<SegmentedList<TokenPairWithOperations>> s_tokenPairListPool =
new
(() => [], trimOnFree: false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\NodeOperations.cs (4)
17
private static readonly ObjectPool<SegmentedList<IndentBlockOperation>> s_indentBlockOperationPool =
new
(() => []);
18
private static readonly ObjectPool<SegmentedList<SuppressOperation>> s_suppressOperationPool =
new
(() => []);
19
private static readonly ObjectPool<SegmentedList<AlignTokensOperation>> s_alignTokensOperationPool =
new
(() => []);
20
private static readonly ObjectPool<SegmentedList<AnchorIndentationOperation>> s_anchorIndentationOperationPool =
new
(() => []);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\SharedPools.cs (6)
44
new
(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase), 20);
50
new
(() => new HashSet<string>(StringComparer.Ordinal), 20);
56
public static readonly ObjectPool<byte[]> ByteArray =
new
(() => new byte[ByteBufferSize], ByteBufferCount);
64
public static readonly ObjectPool<T> Instance =
new
(() => new T(), 100);
69
public static readonly ObjectPool<T> Instance =
new
(() => new T(), 20);
75
new
(() => new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase), 20);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.ReaderReferenceMap.cs (1)
21
=
new
(() => new SegmentedList<string>(20));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
27
public static ObjectPool<T[]> Shared =
new
(() => new T[BufferSize], 512);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.WriterReferenceMap.cs (1)
22
private static readonly ObjectPool<SegmentedDictionary<string, int>> s_valueDictionaryPool =
new
(() => new(128));
136 references to ObjectPool
Microsoft.CodeAnalysis.CodeStyle (136)
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (4)
43
private static readonly
ObjectPool
<ConcurrentStack<AnalysisResult>> s_analysisResultPool = new(() => new());
44
private static readonly
ObjectPool
<ConcurrentSet<SyntaxNode>> s_nodeSetPool = new(() => []);
46
private static readonly
ObjectPool
<ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>>> s_fieldToUsageLocationPool = new(() => []);
51
private readonly
ObjectPool
<HashSet<string>> _fieldNamesPool;
src\Analyzers\Core\Analyzers\UseCollectionInitializer\AbstractObjectCreationExpressionAnalyzer.cs (1)
55
private static readonly
ObjectPool
<TAnalyzer> s_pool = SharedPools.Default<TAnalyzer>();
src\Compilers\Core\Portable\Collections\OrderPreservingMultiDictionary.cs (5)
30
private readonly
ObjectPool
<OrderPreservingMultiDictionary<K, V>>? _pool;
32
private OrderPreservingMultiDictionary(
ObjectPool
<OrderPreservingMultiDictionary<K, V>> pool)
55
private static readonly
ObjectPool
<OrderPreservingMultiDictionary<K, V>> s_poolInstance = CreatePool();
58
public static
ObjectPool
<OrderPreservingMultiDictionary<K, V>> CreatePool()
60
var
pool = new ObjectPool<OrderPreservingMultiDictionary<K, V>>(
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (5)
84
private StringTable(
ObjectPool
<StringTable>? pool)
89
private readonly
ObjectPool
<StringTable>? _pool;
90
private static readonly
ObjectPool
<StringTable> s_staticPool = CreatePool();
92
private static
ObjectPool
<StringTable> CreatePool()
94
var
pool = new ObjectPool<StringTable>(pool => new StringTable(pool), Environment.ProcessorCount * 2);
src\Dependencies\PooledObjects\ArrayBuilder.cs (7)
56
private readonly
ObjectPool
<ArrayBuilder<T>>? _pool;
67
private ArrayBuilder(
ObjectPool
<ArrayBuilder<T>> pool)
428
var
pool = _pool;
459
private static readonly
ObjectPool
<ArrayBuilder<T>> s_poolInstance = CreatePool();
487
public static
ObjectPool
<ArrayBuilder<T>> CreatePool()
492
public static
ObjectPool
<ArrayBuilder<T>> CreatePool(int size)
494
ObjectPool
<ArrayBuilder<T>>? pool = null;
src\Dependencies\PooledObjects\ObjectPool`1.cs (1)
122
internal ObjectPool(Func<
ObjectPool
<T>, T> factory, int size)
src\Dependencies\PooledObjects\PooledDelegates.cs (1)
19
public static readonly
ObjectPool
<T> Instance = new(() => new T(), 20);
src\Dependencies\PooledObjects\PooledDictionary.cs (5)
16
private readonly
ObjectPool
<PooledDictionary<K, V>> _pool;
18
private PooledDictionary(
ObjectPool
<PooledDictionary<K, V>> pool, IEqualityComparer<K> keyComparer)
40
private static readonly
ObjectPool
<PooledDictionary<K, V>> s_poolInstance = CreatePool(EqualityComparer<K>.Default);
43
public static
ObjectPool
<PooledDictionary<K, V>> CreatePool(IEqualityComparer<K> keyComparer)
45
ObjectPool
<PooledDictionary<K, V>>? pool = null;
src\Dependencies\PooledObjects\PooledHashSet.cs (5)
14
private readonly
ObjectPool
<PooledHashSet<T>> _pool;
16
private PooledHashSet(
ObjectPool
<PooledHashSet<T>> pool, IEqualityComparer<T> equalityComparer) :
29
private static readonly
ObjectPool
<PooledHashSet<T>> s_poolInstance = CreatePool(EqualityComparer<T>.Default);
32
public static
ObjectPool
<PooledHashSet<T>> CreatePool(IEqualityComparer<T> equalityComparer)
34
ObjectPool
<PooledHashSet<T>>? pool = null;
src\Dependencies\PooledObjects\PooledStringBuilder.cs (5)
21
private readonly
ObjectPool
<PooledStringBuilder> _pool;
23
private PooledStringBuilder(
ObjectPool
<PooledStringBuilder> pool)
73
private static readonly
ObjectPool
<PooledStringBuilder> s_poolInstance = CreatePool();
81
public static
ObjectPool
<PooledStringBuilder> CreatePool(int size = 32)
83
ObjectPool
<PooledStringBuilder>? pool = null;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\IntervalTreeHelpers.cs (1)
37
private static readonly
ObjectPool
<Stack<TNode>> s_nodeStackPool = new(() => new(), 128, trimOnFree: false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (1)
852
private static readonly
ObjectPool
<Stack<TDirectiveTriviaSyntax>> s_stackPool = new(() => new());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.BasicBlockAnalysisData.cs (1)
23
private static readonly
ObjectPool
<BasicBlockAnalysisData> s_pool =
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\FlowAnalysis\SymbolUsageAnalysis\SymbolUsageAnalysis.Walker.cs (1)
32
private static readonly
ObjectPool
<Walker> s_visitorPool = new(() => new Walker());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormatEngine.cs (1)
36
private static readonly
ObjectPool
<SegmentedList<TokenPairWithOperations>> s_tokenPairListPool = new(() => [], trimOnFree: false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\NodeOperations.cs (4)
17
private static readonly
ObjectPool
<SegmentedList<IndentBlockOperation>> s_indentBlockOperationPool = new(() => []);
18
private static readonly
ObjectPool
<SegmentedList<SuppressOperation>> s_suppressOperationPool = new(() => []);
19
private static readonly
ObjectPool
<SegmentedList<AlignTokensOperation>> s_alignTokensOperationPool = new(() => []);
20
private static readonly
ObjectPool
<SegmentedList<AnchorIndentationOperation>> s_anchorIndentationOperationPool = new(() => []);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\Logger.LogBlock.cs (2)
17
private static readonly
ObjectPool
<RoslynLogBlock> s_pool = new(() => new RoslynLogBlock(s_pool!), Math.Min(Environment.ProcessorCount * 8, 256));
32
private sealed class RoslynLogBlock(
ObjectPool
<RoslynLogBlock> pool) : IDisposable
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\LogMessage.cs (6)
61
private static readonly
ObjectPool
<StaticLogMessage> s_pool = SharedPools.Default<StaticLogMessage>();
89
private static readonly
ObjectPool
<LazyLogMessage> s_pool = SharedPools.Default<LazyLogMessage>();
119
private static readonly
ObjectPool
<LazyLogMessage<TArg0>> s_pool = SharedPools.Default<LazyLogMessage<TArg0>>();
152
private static readonly
ObjectPool
<LazyLogMessage<TArg0, TArg1>> s_pool = SharedPools.Default<LazyLogMessage<TArg0, TArg1>>();
188
private static readonly
ObjectPool
<LazyLogMessage<TArg0, TArg1, TArg2>> s_pool = SharedPools.Default<LazyLogMessage<TArg0, TArg1, TArg2>>();
227
private static readonly
ObjectPool
<LazyLogMessage<TArg0, TArg1, TArg2, TArg3>> s_pool = SharedPools.Default<LazyLogMessage<TArg0, TArg1, TArg2, TArg3>>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\Extensions.cs (35)
18
public static PooledObject<StringBuilder> GetPooledObject(this
ObjectPool
<StringBuilder> pool)
21
public static PooledObject<StringBuilder> GetPooledObject(this
ObjectPool
<StringBuilder> pool, out StringBuilder builder)
28
public static PooledObject<Stack<TItem>> GetPooledObject<TItem>(this
ObjectPool
<Stack<TItem>> pool)
31
public static PooledObject<Queue<TItem>> GetPooledObject<TItem>(this
ObjectPool
<Queue<TItem>> pool)
34
public static PooledObject<HashSet<TItem>> GetPooledObject<TItem>(this
ObjectPool
<HashSet<TItem>> pool)
37
public static PooledObject<Dictionary<TKey, TValue>> GetPooledObject<TKey, TValue>(this
ObjectPool
<Dictionary<TKey, TValue>> pool) where TKey : notnull
40
public static PooledObject<List<TItem>> GetPooledObject<TItem>(this
ObjectPool
<List<TItem>> pool)
43
public static PooledObject<SegmentedList<TItem>> GetPooledObject<TItem>(this
ObjectPool
<SegmentedList<TItem>> pool)
46
public static PooledObject<Stack<TItem>> GetPooledObject<TItem>(this
ObjectPool
<Stack<TItem>> pool, out Stack<TItem> stack)
53
public static PooledObject<List<TItem>> GetPooledObject<TItem>(this
ObjectPool
<List<TItem>> pool, out List<TItem> list)
60
public static PooledObject<SegmentedList<TItem>> GetPooledObject<TItem>(this
ObjectPool
<SegmentedList<TItem>> pool, out SegmentedList<TItem> list)
67
public static PooledObject<HashSet<TItem>> GetPooledObject<TItem>(this
ObjectPool
<HashSet<TItem>> pool, out HashSet<TItem> set)
74
public static PooledObject<Dictionary<TKey, TValue>> GetPooledObject<TKey, TValue>(this
ObjectPool
<Dictionary<TKey, TValue>> pool, out Dictionary<TKey, TValue> dictionary)
82
public static PooledObject<ConcurrentSet<T>> GetPooledObject<T>(this
ObjectPool
<ConcurrentSet<T>> pool, out ConcurrentSet<T> set)
90
public static PooledObject<T> GetPooledObject<T>(this
ObjectPool
<T> pool) where T : class
93
public static StringBuilder AllocateAndClear(this
ObjectPool
<StringBuilder> pool)
101
public static Stack<T> AllocateAndClear<T>(this
ObjectPool
<Stack<T>> pool)
109
public static Queue<T> AllocateAndClear<T>(this
ObjectPool
<Queue<T>> pool)
117
public static HashSet<T> AllocateAndClear<T>(this
ObjectPool
<HashSet<T>> pool)
125
public static ConcurrentSet<T> AllocateAndClear<T>(this
ObjectPool
<ConcurrentSet<T>> pool) where T : notnull
133
public static SegmentedHashSet<T> AllocateAndClear<T>(this
ObjectPool
<SegmentedHashSet<T>> pool)
141
public static Dictionary<TKey, TValue> AllocateAndClear<TKey, TValue>(this
ObjectPool
<Dictionary<TKey, TValue>> pool)
150
public static List<T> AllocateAndClear<T>(this
ObjectPool
<List<T>> pool)
158
public static SegmentedList<T> AllocateAndClear<T>(this
ObjectPool
<SegmentedList<T>> pool)
166
public static void ClearAndFree(this
ObjectPool
<StringBuilder> pool, StringBuilder sb)
183
public static void ClearAndFree<T>(this
ObjectPool
<HashSet<T>> pool, HashSet<T> set)
201
public static void ClearAndFree<T>(this
ObjectPool
<SegmentedHashSet<T>> pool, SegmentedHashSet<T> set)
219
public static void ClearAndFree<T>(this
ObjectPool
<ConcurrentSet<T>> pool, ConcurrentSet<T> set) where T : notnull
235
public static void ClearAndFree<T>(this
ObjectPool
<Stack<T>> pool, Stack<T> stack)
249
public static void ClearAndFree<T>(this
ObjectPool
<ConcurrentStack<T>> pool, ConcurrentStack<T> stack)
265
public static void ClearAndFree<T>(this
ObjectPool
<Queue<T>> pool, Queue<T> set)
283
public static void ClearAndFree<TKey, TValue>(this
ObjectPool
<Dictionary<TKey, TValue>> pool, Dictionary<TKey, TValue> map)
302
public static void ClearAndFree<TKey, TValue>(this
ObjectPool
<ConcurrentDictionary<TKey, TValue>> pool, ConcurrentDictionary<TKey, TValue> map)
319
public static void ClearAndFree<T>(this
ObjectPool
<List<T>> pool, List<T> list, bool trim = true)
336
public static void ClearAndFree<T>(this
ObjectPool
<SegmentedList<T>> pool, SegmentedList<T> list, bool trim = true)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\PooledObject.cs (29)
19
private readonly Action<
ObjectPool
<T>, T> _releaser;
20
private readonly
ObjectPool
<T> _pool;
22
public PooledObject(
ObjectPool
<T> pool, Func<
ObjectPool
<T>, T> allocator, Action<
ObjectPool
<T>, T> releaser) : this()
41
public static PooledObject<StringBuilder> Create(
ObjectPool
<StringBuilder> pool)
49
public static PooledObject<Stack<TItem>> Create<TItem>(
ObjectPool
<Stack<TItem>> pool)
57
public static PooledObject<Queue<TItem>> Create<TItem>(
ObjectPool
<Queue<TItem>> pool)
65
public static PooledObject<HashSet<TItem>> Create<TItem>(
ObjectPool
<HashSet<TItem>> pool)
73
public static PooledObject<ConcurrentSet<TItem>> Create<TItem>(
ObjectPool
<ConcurrentSet<TItem>> pool) where TItem : notnull
81
public static PooledObject<Dictionary<TKey, TValue>> Create<TKey, TValue>(
ObjectPool
<Dictionary<TKey, TValue>> pool)
90
public static PooledObject<List<TItem>> Create<TItem>(
ObjectPool
<List<TItem>> pool)
98
public static PooledObject<SegmentedList<TItem>> Create<TItem>(
ObjectPool
<SegmentedList<TItem>> pool)
109
private static StringBuilder Allocator(
ObjectPool
<StringBuilder> pool)
112
private static void Releaser(
ObjectPool
<StringBuilder> pool, StringBuilder sb)
115
private static Stack<TItem> Allocator<TItem>(
ObjectPool
<Stack<TItem>> pool)
118
private static void Releaser<TItem>(
ObjectPool
<Stack<TItem>> pool, Stack<TItem> obj)
121
private static Queue<TItem> Allocator<TItem>(
ObjectPool
<Queue<TItem>> pool)
124
private static void Releaser<TItem>(
ObjectPool
<Queue<TItem>> pool, Queue<TItem> obj)
127
private static HashSet<TItem> Allocator<TItem>(
ObjectPool
<HashSet<TItem>> pool)
130
private static ConcurrentSet<TItem> Allocator<TItem>(
ObjectPool
<ConcurrentSet<TItem>> pool) where TItem : notnull
133
private static void Releaser<TItem>(
ObjectPool
<HashSet<TItem>> pool, HashSet<TItem> obj)
136
private static void Releaser<TItem>(
ObjectPool
<ConcurrentSet<TItem>> pool, ConcurrentSet<TItem> obj) where TItem : notnull
139
private static Dictionary<TKey, TValue> Allocator<TKey, TValue>(
ObjectPool
<Dictionary<TKey, TValue>> pool)
143
private static void Releaser<TKey, TValue>(
ObjectPool
<Dictionary<TKey, TValue>> pool, Dictionary<TKey, TValue> obj)
147
private static List<TItem> Allocator<TItem>(
ObjectPool
<List<TItem>> pool)
150
private static void Releaser<TItem>(
ObjectPool
<List<TItem>> pool, List<TItem> obj)
153
private static SegmentedList<TItem> Allocator<TItem>(
ObjectPool
<SegmentedList<TItem>> pool)
156
private static void Releaser<TItem>(
ObjectPool
<SegmentedList<TItem>> pool, SegmentedList<TItem> obj)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\ObjectPools\SharedPools.cs (9)
25
public static
ObjectPool
<T> BigDefault<T>() where T : class, new()
31
public static
ObjectPool
<T> Default<T>() where T : class, new()
37
public static
ObjectPool
<Dictionary<string, T>> StringIgnoreCaseDictionary<T>()
43
public static readonly
ObjectPool
<HashSet<string>> StringIgnoreCaseHashSet =
49
public static readonly
ObjectPool
<HashSet<string>> StringHashSet =
56
public static readonly
ObjectPool
<byte[]> ByteArray = new(() => new byte[ByteBufferSize], ByteBufferCount);
64
public static readonly
ObjectPool
<T> Instance = new(() => new T(), 100);
69
public static readonly
ObjectPool
<T> Instance = new(() => new T(), 20);
74
public static readonly
ObjectPool
<Dictionary<string, T>> Instance =
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectReader.ReaderReferenceMap.cs (1)
20
private static readonly
ObjectPool
<SegmentedList<string>> s_objectListPool
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
27
public static
ObjectPool
<T[]> Shared = new(() => new T[BufferSize], 512);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.WriterReferenceMap.cs (1)
22
private static readonly
ObjectPool
<SegmentedDictionary<string, int>> s_valueDictionaryPool = new(() => new(128));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (1)
20
private static readonly
ObjectPool
<Stack<(SyntaxNodeOrToken nodeOrToken, bool leading, bool trailing)>> s_stackPool
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (1)
322
private static readonly
ObjectPool
<SymbolKeyReader> s_readerPool = SharedPools.Default<SymbolKeyReader>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
56
private static readonly
ObjectPool
<SymbolKeyWriter> s_writerPool = SharedPools.Default<SymbolKeyWriter>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (1)
53
private static readonly
ObjectPool
<char[]> s_pool = new ObjectPool<char[]>(() => new char[PooledArraySize]);