Refactorizations:

- Removed empty implementation of CheckUninitVar::runChecks()
- Avoided unnecessary string copying
This commit is contained in:
PKEuS 2013-03-12 08:11:18 -07:00
parent 796c3e101f
commit 292e52364c
2 changed files with 3 additions and 9 deletions

View File

@ -47,13 +47,6 @@ public:
: Check(myName(), tokenizer, settings, errorLogger)
{ }
/** @brief Run checks against the normal token list */
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
CheckUninitVar checkUninitVar(tokenizer, settings, errorLogger);

View File

@ -757,8 +757,9 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
// bailout when for_each is used
if (Token::Match(tok,"%var% (") && Token::simpleMatch(tok->linkAt(1),") {")) {
// does the name contain "for_each" or "foreach"?
std::string nameTok(tok->str());
std::transform(nameTok.begin(),nameTok.end(),nameTok.begin(),::tolower);
std::string nameTok;
nameTok.resize(tok->str().size());
std::transform(tok->str().begin(), tok->str().end(), nameTok.begin(), ::tolower);
if (nameTok.find("foreach") != std::string::npos || nameTok.find("for_each") != std::string::npos) {
// bailout all variables in the body that are used more than once.
// TODO: there is no need to bailout if variable is only read or only written