[SERVER-1269] BSON headers provide no way to give the length of a c string when used as a key or value Created: 21/Jun/10 Updated: 24/Jan/15 Resolved: 20/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | 1.5.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Andrew Morrow (Inactive) | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
Consider the following code: const char kKey[] = "key"; This is going to cause two calls to strlen which certainly don't need to be made, since the lengths of kKey and kValue are known at compile time. For such cases, it would be nice to have a mechanism to pass the already known size down to the BSONObjBuilder: someBSONObjBuilder.append(key, sizeof(key), value, sizeof(value)); Similar overloads would need to be made for each type'd BSONObjBuilder::append(key, sizeof(key), T), and for BSONArrayBuilder. |
| Comments |
| Comment by auto [ 23/Jul/10 ] |
|
Author: {'login': 'alerner', 'name': 'Alberto Lerner', 'email': 'alerner@10gen.com'}Message: |
| Comment by Alberto Lerner [ 23/Jul/10 ] |
|
Second parameter still can't take a StringData argument but the first parameter can already skip the unnecessary strlen() example usage: |