[SERVER-1496] StringData should have an explicit constructor taking both a const char* and a length Created: 27/Jul/10  Updated: 12/Jul/16  Resolved: 28/Jul/10

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 1.5.6
Fix Version/s: 1.5.7

Type: Improvement Priority: Minor - P4
Reporter: Andrew Morrow (Inactive) Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

all


Participants:

 Description   

If you already know the length of a const char*, but that const char* doesn't happen to be a string literal, there is currently no way to construct a StringData object that captures both the string pointer and the known length without an additional call to strlen. Adding an new constructor that takes a const char* and a length would fix this.

I have a patch for this in progress and I will post a github pull request with the fix later today, so feel free to assign it to me, or to Alberto if that is not possible.



 Comments   
Comment by auto [ 27/Jul/10 ]

Author:

{'login': 'acmorrow', 'name': 'Andrew C. Morrow', 'email': 'andrew.c.morrow@gmail.com'}

Message: SERVER-1496: Add explicit data/length ctor to StringData
http://github.com/mongodb/mongo/commit/0553e3c38188cba8b12a9387a49cecc6faeff05f

Generated at Thu Feb 08 02:57:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.