Make StringRef's operator std::string explicit
This way it is explicit when there is a `StringRef` -> `std::string` conversion and makes it easier to look for allocations that could be avoided. Doing this has already removed one allocation per registered test case, as there was a completely pointless `StringRef` -> `std::string` conversion when parsing tags of a test case.
This commit is contained in:
parent
14362533bb
commit
7b865daccc
13 changed files with 23 additions and 67 deletions
|
@ -59,8 +59,7 @@ namespace Catch {
|
|||
std::vector<std::string> tags;
|
||||
std::string desc, tag;
|
||||
bool inTag = false;
|
||||
std::string _descOrTags = nameAndTags.tags;
|
||||
for (char c : _descOrTags) {
|
||||
for (char c : nameAndTags.tags) {
|
||||
if( !inTag ) {
|
||||
if( c == '[' )
|
||||
inTag = true;
|
||||
|
@ -93,7 +92,7 @@ namespace Catch {
|
|||
tags.push_back( "." );
|
||||
}
|
||||
|
||||
TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo );
|
||||
TestCaseInfo info( static_cast<std::string>(nameAndTags.name), _className, desc, tags, _lineInfo );
|
||||
return TestCase( _testCase, std::move(info) );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue