Skip to content

Commit 1f1d87a

Browse files
committed
tokenize.cpp: avoid unnecessary copies with ScopeInfo3::addChild() [skip ci]
1 parent 4c62867 commit 1f1d87a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

lib/tokenize.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,8 +2405,8 @@ namespace {
24052405
std::set<std::string> recordTypes;
24062406
std::set<std::string> baseTypes;
24072407

2408-
ScopeInfo3 *addChild(Type scopeType, const std::string &scopeName, const Token *bodyStartToken, const Token *bodyEndToken) {
2409-
children.emplace_back(this, scopeType, scopeName, bodyStartToken, bodyEndToken);
2408+
ScopeInfo3 *addChild(Type scopeType, std::string scopeName, const Token *bodyStartToken, const Token *bodyEndToken) {
2409+
children.emplace_back(this, scopeType, std::move(scopeName), bodyStartToken, bodyEndToken);
24102410
return &children.back();
24112411
}
24122412

@@ -2554,13 +2554,13 @@ namespace {
25542554
scope = tok1->strAt(-3) + " :: " + scope;
25552555
tok1 = tok1->tokAt(-2);
25562556
}
2557-
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
2557+
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, std::move(scope), tok, tok->link());
25582558
added = true;
25592559
}
25602560
// inline member function
25612561
else if ((scopeInfo->type == ScopeInfo3::Record || scopeInfo->type == ScopeInfo3::Namespace) && tok1 && Token::Match(tok1->tokAt(-1), "%name% (")) {
2562-
const std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
2563-
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
2562+
std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
2563+
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, std::move(scope), tok, tok->link());
25642564
added = true;
25652565
}
25662566
}
@@ -2621,7 +2621,7 @@ namespace {
26212621
}
26222622

26232623
if (tok && tok->str() == "{") {
2624-
scopeInfo = scopeInfo->addChild(record ? ScopeInfo3::Record : ScopeInfo3::Namespace, classname, tok, tok->link());
2624+
scopeInfo = scopeInfo->addChild(record ? ScopeInfo3::Record : ScopeInfo3::Namespace, std::move(classname), tok, tok->link());
26252625
scopeInfo->baseTypes = std::move(baseTypes);
26262626
}
26272627
}

0 commit comments

Comments
 (0)