File tree 1 file changed +5
-1
lines changed
src/Common/src/CoreLib/System/Buffers 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ namespace System.Buffers
19
19
/// </remarks>
20
20
public abstract class ArrayPool < T >
21
21
{
22
+ // Store the shared ArrayPool in a field of its derived sealed type so the Jit can "see" the exact type
23
+ // when the Shared property is inlined which will allow it to devirtualize calls made on it.
24
+ private readonly static TlsOverPerCoreLockedStacksArrayPool < T > s_shared = new TlsOverPerCoreLockedStacksArrayPool < T > ( ) ;
25
+
22
26
/// <summary>
23
27
/// Retrieves a shared <see cref="ArrayPool{T}"/> instance.
24
28
/// </summary>
@@ -33,7 +37,7 @@ public abstract class ArrayPool<T>
33
37
/// optimized for very fast access speeds, at the expense of more memory consumption.
34
38
/// The shared pool instance is created lazily on first access.
35
39
/// </remarks>
36
- public static ArrayPool < T > Shared { get ; } = new TlsOverPerCoreLockedStacksArrayPool < T > ( ) ;
40
+ public static ArrayPool < T > Shared => s_shared ;
37
41
38
42
/// <summary>
39
43
/// Creates a new <see cref="ArrayPool{T}"/> instance using default configuration options.
You can’t perform that action at this time.
0 commit comments