mongo-csharp-driver
mongo-csharp-driver copied to clipboard
CSHARP-5125 Span support for ObjectId ctor, Parse, TryParse, BsonUtils hex conversion
- Eliminated unneeded allocations from Parse and ToString()
- Added Span overloads for ctor, Parse, TryParse, ToHexChars, ToByteSpan methods.
Local benchmark results:
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|---|---|---|---|---|---|
| ToString_Original | 33.47 ns | 2.004 ns | 5.877 ns | 0.0172 | 144 B |
| ToString_New | 35.48 ns | 0.713 ns | 0.792 ns | 0.0086 | 72 B |
| Parse_Original | 33.72 ns | 0.699 ns | 0.546 ns | 0.0048 | 40 B |
| Parse_New | 26.23 ns | 0.547 ns | 1.311 ns | - | - |
Thanks @Kloizdena for your PR. CSHARP-5125 is not a priority in the upcoming quarter. We will consider this PR when CSHARP-5125 gets scheduled as part of our serialization improvement effort.