[SERVER-13600] Remove copying implicit conversions between NamespaceString and std::string. Created: 15/Apr/14  Updated: 11/Jul/16  Resolved: 15/Apr/14

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 2.7.0

Type: Improvement Priority: Minor - P4
Reporter: Andy Schwerin Assignee: Andy Schwerin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

These implicit conversions are dangerous when combined with pass-by-reference, plus they introduce unexpected copies.

While it would be ideal to remove all implicit conversion between the types, an expedient step along the way is to remove implicit construction of NamespaceStrings and std::strings, while still allowing implicit casting from const NamespaceString& to std::string&.



 Comments   
Comment by Githook User [ 15/Apr/14 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: SERVER-13600 Remove string-copying implicit conversion operator from NamespaceString to std::string.

By replacing the implicit conversion operator from const
NamespaceString&>std::string with one from const NamespaceString&>const
std::string&, we at least eliminate an implicit copy. Better might be to get
rid of the implicit conversion entirely, but we might want to start by removing
APIs that take std::string when they mean NamespaceString.
Branch: master
https://github.com/mongodb/mongo/commit/194676d5d68993abc3fa709d0661850e699dc154

Comment by Githook User [ 15/Apr/14 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: SERVER-13600 Forbid implicit construction of NamespaceString from StringData.
Branch: master
https://github.com/mongodb/mongo/commit/044e2d91a089efd7da2e044a29dc875c12e5a548

Generated at Thu Feb 08 03:32:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.