Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2391

Provide an overload for JsonWriter.WriteValue to accept Span<byte> input

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.7.0
    • Component/s: BSON, Json, Performance
    • Fully Compatible
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ugur.pelister@outlook.com Uğur Pelister
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: