|
Right now, the bsonExtractStringField function is written so that the string to be returned is provided as an 'out parameter' - a pointer to a std::string is the last argument to the function.
The code generated for that function must assume that the pointed to string may be already populated with data, and thus must emit code to potentially clean any current state out of the string, leading to larger codegen sprinkled with calls to operator delete[].
If the bsonExtract function instead returned a StatusWith<std::string>, the returned string would be known to be new, and simpler code could potentially be emitted.
Overall, it would also be stylish to upgrade the remaining functions in bson_extract.h to return StatusWith<T> rather than using out parameters.
|