Some small refactorizations:

- Removed redundant calls to std::string constructor
- Use default parameters in some places
This commit is contained in:
PKEuS 2014-10-03 10:02:46 +02:00
parent bb8c8d53cc
commit a02712cb66
4 changed files with 7 additions and 9 deletions

View File

@ -215,7 +215,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
if (_settings._errorsOnly == false && it != configurations.begin()) {
std::string fixedpath = Path::simplifyPath(filename);
fixedpath = Path::toNativeSeparators(fixedpath);
_errorLogger.reportOut(std::string("Checking ") + fixedpath + ": " + cfg + std::string("..."));
_errorLogger.reportOut("Checking " + fixedpath + ": " + cfg + "...");
}
if (!_settings.userDefines.empty()) {
@ -311,7 +311,7 @@ void CppCheck::analyseFile(std::istream &fin, const std::string &filename)
// Tokenize..
Tokenizer tokenizer(&_settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, filename.c_str(), "");
tokenizer.tokenize(istr, filename.c_str());
tokenizer.simplifyTokenList2();
// Analyse the tokens..
@ -340,8 +340,6 @@ bool CppCheck::checkFile(const std::string &code, const char FileName[], std::se
if (_settings._showtime != SHOWTIME_NONE)
_tokenizer.setTimerResults(&S_timerResults);
try {
bool result;
// Execute rules for "raw" code
for (std::list<Settings::Rule>::const_iterator it = _settings.rules.begin(); it != _settings.rules.end(); ++it) {
if (it->tokenlist == "raw") {
@ -357,7 +355,7 @@ bool CppCheck::checkFile(const std::string &code, const char FileName[], std::se
std::istringstream istr(code);
Timer timer("Tokenizer::tokenize", _settings._showtime, &S_timerResults);
result = _tokenizer.tokenize(istr, FileName, cfg);
bool result = _tokenizer.tokenize(istr, FileName, cfg);
timer.Stop();
if (_settings._force || _settings._maxConfigs > 1) {

View File

@ -396,7 +396,7 @@ bool Library::isargvalid(const std::string &functionName, int argnr, const MathL
return true;
TokenList tokenList(0);
std::istringstream istr(ac->valid + ',');
tokenList.createTokens(istr,"");
tokenList.createTokens(istr);
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
if (Token::Match(tok,"- %num%")) {
tok->str("-" + tok->strAt(1));

View File

@ -1622,7 +1622,7 @@ bool Tokenizer::tokenizeCondition(const std::string &code)
{
std::istringstream istr(code);
if (!list.createTokens(istr, "")) {
if (!list.createTokens(istr)) {
cppcheckError(0);
return false;
}

View File

@ -3757,7 +3757,7 @@ private:
Settings settings;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp", "");
tokenizer.tokenize(istr, "test.cpp");
tokenizer.validate();
}
@ -3768,7 +3768,7 @@ private:
Settings settings;
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp", "");
tokenizer.tokenize(istr, "test.cpp");
tokenizer.validate();
}