Skip to content

Commit

Permalink
Refactorizations:
Browse files Browse the repository at this point in the history
- Removed empty implementation of CheckUninitVar::runChecks()
- Avoided unnecessary string copying
  • Loading branch information
PKEuS committed Mar 12, 2013
1 parent 796c3e1 commit 292e523
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 0 additions & 7 deletions lib/checkuninitvar.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ class CPPCHECKLIB CheckUninitVar : public Check {
: Check(myName(), tokenizer, settings, errorLogger) : 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 */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) { void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
CheckUninitVar checkUninitVar(tokenizer, settings, errorLogger); CheckUninitVar checkUninitVar(tokenizer, settings, errorLogger);
Expand Down
5 changes: 3 additions & 2 deletions lib/checkunusedvar.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -757,8 +757,9 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
// bailout when for_each is used // bailout when for_each is used
if (Token::Match(tok,"%var% (") && Token::simpleMatch(tok->linkAt(1),") {")) { if (Token::Match(tok,"%var% (") && Token::simpleMatch(tok->linkAt(1),") {")) {
// does the name contain "for_each" or "foreach"? // does the name contain "for_each" or "foreach"?
std::string nameTok(tok->str()); std::string nameTok;
std::transform(nameTok.begin(),nameTok.end(),nameTok.begin(),::tolower); 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) { 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. // 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 // TODO: there is no need to bailout if variable is only read or only written
Expand Down

0 comments on commit 292e523

Please sign in to comment.