Make expensive string manipulation depend on settings
This commit is contained in:
parent
ec2c4aa2e3
commit
ff6604e289
|
@ -10238,6 +10238,8 @@ void Tokenizer::removeUnnecessaryQualification()
|
||||||
if (isC())
|
if (isC())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const bool portabilityEnabled = _settings->isEnabled("portability");
|
||||||
|
|
||||||
std::vector<Space> classInfo;
|
std::vector<Space> classInfo;
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "class|struct|namespace %type% :|{") &&
|
if (Token::Match(tok, "class|struct|namespace %type% :|{") &&
|
||||||
|
@ -10277,7 +10279,9 @@ void Tokenizer::removeUnnecessaryQualification()
|
||||||
tok1 = tok1->next();
|
tok1 = tok1->next();
|
||||||
|
|
||||||
if (tok1 && Token::Match(tok1->link(), ") const| {|;|:")) {
|
if (tok1 && Token::Match(tok1->link(), ") const| {|;|:")) {
|
||||||
std::string qualification = tok->str() + "::";
|
std::string qualification;
|
||||||
|
if (portabilityEnabled)
|
||||||
|
qualification = tok->str() + "::";
|
||||||
|
|
||||||
// check for extra qualification
|
// check for extra qualification
|
||||||
/** @todo this should be made more generic to handle more levels */
|
/** @todo this should be made more generic to handle more levels */
|
||||||
|
@ -10285,13 +10289,13 @@ void Tokenizer::removeUnnecessaryQualification()
|
||||||
if (classInfo.size() >= 2) {
|
if (classInfo.size() >= 2) {
|
||||||
if (classInfo[classInfo.size() - 2].className != tok->strAt(-2))
|
if (classInfo[classInfo.size() - 2].className != tok->strAt(-2))
|
||||||
continue;
|
continue;
|
||||||
else
|
if (portabilityEnabled)
|
||||||
qualification = tok->strAt(-2) + "::" + qualification;
|
qualification = tok->strAt(-2) + "::" + qualification;
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings->isEnabled("portability"))
|
if (portabilityEnabled)
|
||||||
unnecessaryQualificationError(tok, qualification);
|
unnecessaryQualificationError(tok, qualification);
|
||||||
|
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
|
Loading…
Reference in New Issue