Browse files

Refactorizations:

- Removed empty implementation of CheckUninitVar::runChecks()
- Avoided unnecessary string copying
  • Loading branch information...
1 parent 796c3e1 commit 292e52364c410fdcb8f17273bc0cea4b3220a04a @PKEuS PKEuS committed Mar 12, 2013
Showing with 3 additions and 9 deletions.
  1. +0 −7 lib/checkuninitvar.h
  2. +3 −2 lib/checkunusedvar.cpp
View
7 lib/checkuninitvar.h
@@ -47,13 +47,6 @@ class CPPCHECKLIB CheckUninitVar : public Check {
: 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
5 lib/checkunusedvar.cpp
@@ -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

0 comments on commit 292e523

Please sign in to comment.