[CSHARP-2391] Provide an overload for JsonWriter.WriteValue to accept Span<byte> input Created: 21/Sep/18 Updated: 31/Mar/22 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | BSON, Json, Performance |
| Affects Version/s: | 2.7.0 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Uğur Pelister | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||
| Description |
|
The recently introduced Span<T> offers advantages, specifically obviating the need to deal with byte buffers in most cases. I started to use it in my code, too, but the C# driver's JsonWriter.WriteValue method won't accept Span<byte> and a span has to be converted to a byte array first, which results in a heap allocation: span.ToArray(). The driver should support this new .NET type so that we can use it without such unnecessary allocation penalties. |
| Comments |
| Comment by Robert Stam [ 02/Oct/18 ] |
|
Using Span<T> is only possible on newer versions of .NET Framework and .NET Standard. Before we can add support for Span<T> we need to add new target frameworks to our build system, and make support for Span<T> conditional to just the target frameworks that support it. |