Details
-
Improvement
-
Resolution: Won't Fix
-
Minor - P4
-
None
-
None
-
None
Description
string::view_or_value can be constructed from a const char*. This must be a null terminated string.
The bsoncxx::string::view_or_value has a terminated method, which guarantees to return a view_or_value containing a null terminated representation of the string. This does not take into account the case where the view_or_value was constructed with a const char*, copying it when it really doesn't need to.
We should add a boolean member to string::view_or_value to remember if it was constructed with a const char*, and if so, avoid copying when returning a null terminated view_or_value.