Skip to content

Commit 2064919

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

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
@@ -2385,8 +2385,8 @@ namespace {
23852385
std::set<std::string> recordTypes;
23862386
std::set<std::string> baseTypes;
23872387

2388-
ScopeInfo3 *addChild(Type scopeType, const std::string &scopeName, const Token *bodyStartToken, const Token *bodyEndToken) {
2389-
children.emplace_back(this, scopeType, scopeName, bodyStartToken, bodyEndToken);
2388+
ScopeInfo3 *addChild(Type scopeType, std::string scopeName, const Token *bodyStartToken, const Token *bodyEndToken) {
2389+
children.emplace_back(this, scopeType, std::move(scopeName), bodyStartToken, bodyEndToken);
23902390
return &children.back();
23912391
}
23922392

@@ -2534,13 +2534,13 @@ namespace {
25342534
scope = tok1->strAt(-3) + " :: " + scope;
25352535
tok1 = tok1->tokAt(-2);
25362536
}
2537-
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
2537+
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, std::move(scope), tok, tok->link());
25382538
added = true;
25392539
}
25402540
// inline member function
25412541
else if ((scopeInfo->type == ScopeInfo3::Record || scopeInfo->type == ScopeInfo3::Namespace) && tok1 && Token::Match(tok1->tokAt(-1), "%name% (")) {
2542-
const std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
2543-
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
2542+
std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
2543+
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, std::move(scope), tok, tok->link());
25442544
added = true;
25452545
}
25462546
}
@@ -2601,7 +2601,7 @@ namespace {
26012601
}
26022602

26032603
if (tok && tok->str() == "{") {
2604-
scopeInfo = scopeInfo->addChild(record ? ScopeInfo3::Record : ScopeInfo3::Namespace, classname, tok, tok->link());
2604+
scopeInfo = scopeInfo->addChild(record ? ScopeInfo3::Record : ScopeInfo3::Namespace, std::move(classname), tok, tok->link());
26052605
scopeInfo->baseTypes = std::move(baseTypes);
26062606
}
26072607
}

0 commit comments

Comments
 (0)