-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Change SqlClient to use strongly typed packet and session handles #33155
Changes from 4 commits
8cb721c
534697a
d14f23d
8cbec8c
fbed8d5
ec38cf5
022fadd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ internal class SNIPacket : IDisposable, IEquatable<SNIPacket> | |
| private string _description; | ||
| private SNIAsyncCallback _completionCallback; | ||
|
|
||
| private ArrayPool<byte> _arrayPool = ArrayPool<byte>.Shared; | ||
| //private ArrayPool<byte> _arrayPool = ArrayPool<byte>.Shared; | ||
|
Wraith2 marked this conversation as resolved.
Outdated
|
||
| private bool _isBufferFromArrayPool = false; | ||
|
|
||
| public SNIPacket() { } | ||
|
|
@@ -98,14 +98,14 @@ public void Allocate(int capacity) | |
| { | ||
| if (_isBufferFromArrayPool) | ||
| { | ||
| _arrayPool.Return(_data); | ||
| ArrayPool<byte>.Shared.Return(_data); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the default shared pool is being used it seems wasteful to carry around the extra field referring to it. The default pool can also be devirtualized by the jit possibly making the calls slightly faster.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yep, when referred to directly via |
||
| } | ||
| _data = null; | ||
| } | ||
|
|
||
| if (_data == null) | ||
| { | ||
| _data = _arrayPool.Rent(capacity); | ||
| _data = ArrayPool<byte>.Shared.Rent(capacity); | ||
| _isBufferFromArrayPool = true; | ||
| } | ||
|
|
||
|
|
@@ -221,7 +221,7 @@ public void Release() | |
| { | ||
| if(_isBufferFromArrayPool) | ||
| { | ||
| _arrayPool.Return(_data); | ||
| ArrayPool<byte>.Shared.Return(_data); | ||
| } | ||
| _data = null; | ||
| _capacity = 0; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.