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

Provide overloads for WriteBytes/ReadBytes methods that allow buffer reuse

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.7.0
    • Component/s: BSON
    • Labels:
      None
    • Fully Compatible

      I'd like to reuse one allocated buffer to read and one buffer to write to the mongodb. Currently one must use WriteBytes(byte[]) and byte[] ReadBytes() to read and write byte arrays. These arrays must be pre allocated with the correct size.

      If you want to reuse a buffer it would be nice to get some overloads with a size restriction like:

       

      void IBsonWriter.WriteBytes(byte[] bytes, int size);

      This overload should only write size bytes to the document.

       

      void IBsonWriter.ReadBytes(byte[] buffer, int offset, int size);

      This overload should only fill the count of bytes defined by size starting at offset. 

       

      This would reduce memory fragmentation in the program.

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            bpiorczig Benjamin Piorczig
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: