Make expensive string manipulation depend on settings

This commit is contained in:
Dmitry-Me 2014-12-09 06:08:38 +01:00 committed by Daniel Marjamäki
parent ec2c4aa2e3
commit ff6604e289
1 changed files with 7 additions and 3 deletions

View File

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