[SERVER-71780] Return StringData from DatabaseName::db() Created: 01/Dec/22  Updated: 29/Jun/23  Resolved: 29/Jun/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Dan Larkin-York Assignee: [DO NOT USE] Backlog - Server Serverless (Inactive)
Resolution: Done Votes: 0
Labels: ntdi_nice_to_have
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-71721 Avoid extra string copy in NamespaceS... Closed
Assigned Teams:
Serverless
Backwards Compatibility: Fully Compatible
Participants:
Story Points: 2

 Description   

Currently, DatabaseName::db() returns a const std::string&, which is fine for the most part. However, it's easy to assign the output in a way that copies the underlying string without realizing it (e.g. auto db = dbName.db() instead of const auto& db = dbName.db()). Changing the return type to StringData would require the caller to opt-in to copy behavior via StringData::toString(), or simply calling DatabaseName::toString() to begin with.



 Comments   
Comment by Sophia Tan [ 29/Jun/23 ]

This task has been done by SERVER-75733

Comment by Sophia Tan [ 27/Jun/23 ]

We decided to make the "DatabaseName::db()" and "NamespaceString::db()" private. See the tickets SERVER-77537 and SERVER-65456. Once these tickets completed, the issue described by this ticket will be automatically avoided. 

Generated at Thu Feb 08 06:19:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.