-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.7.3
-
Component/s: Performance, Serialization
-
None
BsonStreamAdapter already uses some kind of an array reuse concept using the _tempUtf8 variable. This approach could, however, be significantly improved by dropping this helper variable and instead switching to System.Buffers.ArrayPool<byte>. The reason being that e.g. for the UTF8 conversions in WriteString() and WriteCString, the buffers are only needed for a very short time and can immediately (at the end of the very same method) be returned back to the pool once the buffer has been written into the output stream.