[CXX-1633] Getting a null terminated string::view_or_value may copy unnecessarily Created: 08/Aug/18  Updated: 06/Sep/18  Resolved: 06/Sep/18

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Won't Fix Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 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.



 Comments   
Comment by Kevin Albertson [ 06/Sep/18 ]

Agreed, string::view_or_value isn't used much anyway.

Generated at Wed Feb 07 22:03:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.