[SERVER-30172] Allow accessing StringData from a string-typed Value Created: 17/Jul/17  Updated: 06/Dec/22  Resolved: 08/Feb/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-31477 Support of LTRIM RTRIM TRIM function ... Closed
Assigned Teams:
Query
Participants:

 Description   

The Value class currently exposes a getString() method, and has a private getStringData() method that does not do type checking.

Many callers just need to read and compare the value of a string stored in a Value, so would benefit from the StringData version of this interface. We should expose a version of getStringData that does type checking. Since a StringData is just a reference to a string owned elsewhere, such a method could potentially be used incorrectly in a line of code such as:

auto myString = doc["stringField"].getStringData();  // Returning pointer to memory about to be de-allocated.

This should be avoided by deleting the r-value override of getStringData(). As part of this work, we should consider auditing existing callers of getString() to see if they could use getStringData() instead and see a performance improvement.



 Comments   
Comment by Charlie Swanson [ 08/Feb/18 ]

This was resolved as part of SERVER-31477.

Generated at Thu Feb 08 04:22:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.