提交 30471ffb 编写于 作者: B Ben Adams 提交者: Stephen Toub

Allow MemoryPool.Shared devirtualization (dotnet/corefx#33085)



Commit migrated from https://github.com/dotnet/corefx/commit/c5cad0cdbee20f2c5f392f3e4b19c71a274b2f2e
上级 aa978495
......@@ -9,7 +9,13 @@ namespace System.Buffers
/// </summary>
public abstract class MemoryPool<T> : IDisposable
{
private static readonly MemoryPool<T> s_shared = new ArrayMemoryPool<T>();
// Store the shared ArrayMemoryPool in a field of its derived sealed type so the Jit can "see" the exact type
// when the Shared property is inlined which will allow it to devirtualize calls made on it.
//
// Roslyn proposal https://github.com/dotnet/roslyn/issues/30797 where field initalizer,
// backing field and property could be combined via `{ get } = ` to support devirtualization
// by having the auto-backing field be created as the derived type rather than the exposed type.
private static readonly ArrayMemoryPool<T> s_shared = new ArrayMemoryPool<T>();
/// <summary>
/// Returns a singleton instance of a MemoryPool based on arrays.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册