Skip to content

Commit 5c240c0

Browse files
committed
tokenize.cpp: avoid unnecessary copies with ScopeInfo3::addChild() [skip ci]
1 parent 3a3b0fd commit 5c240c0

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
@@ -2404,8 +2404,8 @@ namespace {
24042404
std::set<std::string> recordTypes;
24052405
std::set<std::string> baseTypes;
24062406

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

@@ -2553,13 +2553,13 @@ namespace {
25532553
scope = tok1->strAt(-3) + " :: " + scope;
25542554
tok1 = tok1->tokAt(-2);
25552555
}
2556-
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
2556+
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, std::move(scope), tok, tok->link());
25572557
added = true;
25582558
}
25592559
// inline member function
25602560
else if ((scopeInfo->type == ScopeInfo3::Record || scopeInfo->type == ScopeInfo3::Namespace) && tok1 && Token::Match(tok1->tokAt(-1), "%name% (")) {
2561-
const std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
2562-
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
2561+
std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
2562+
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, std::move(scope), tok, tok->link());
25632563
added = true;
25642564
}
25652565
}
@@ -2620,7 +2620,7 @@ namespace {
26202620
}
26212621

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

0 commit comments

Comments
 (0)