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: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.7.0
    • Component/s: BSON
    • None
    • 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?

      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:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: