From c25ab16f5d564e88e0fa78d566127679556b10a6 Mon Sep 17 00:00:00 2001 From: Pavel Pimenov Date: Sun, 17 Jun 2018 17:39:28 +0300 Subject: [PATCH] V817 It is more efficient to seek '\t' character rather than a string. errorlogger.cpp 448 (#1290) V817 It is more efficient to seek '}' character rather than a string. errorlogger.cpp 484 V817 It is more efficient to seek '\r' character rather than a string. errorlogger.cpp 497 V817 It is more efficient to seek '\r' character rather than a string. errorlogger.cpp 528 V817 It is more efficient to seek ';' character rather than a string. suppressions.cpp 187 V817 It is more efficient to seek ';' character rather than a string. suppressions.cpp 188 full log: http://www.fly-server.ru/pvs-studio/cppcheck/ --- lib/errorlogger.cpp | 8 ++++---- lib/suppressions.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 8eb22cfd8..f21641e42 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -445,7 +445,7 @@ static std::string readCode(const std::string &file, unsigned int linenr, unsign if (endPos + 1 < line.size()) line.erase(endPos + 1); std::string::size_type pos = 0; - while ((pos = line.find("\t", pos)) != std::string::npos) + while ((pos = line.find('\t', pos)) != std::string::npos) line[pos] = ' '; return line + endl + std::string((column>0 ? column-1 : column), ' ') + '^'; } @@ -481,7 +481,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string findAndReplace(result, "{id}", _id); if (result.find("{inconclusive:") != std::string::npos) { const std::string::size_type pos1 = result.find("{inconclusive:"); - const std::string::size_type pos2 = result.find("}", pos1+1); + const std::string::size_type pos2 = result.find('}', pos1+1); const std::string replaceFrom = result.substr(pos1,pos2-pos1+1); const std::string replaceWith = _inconclusive ? result.substr(pos1+14, pos2-pos1-14) : std::string(); findAndReplace(result, replaceFrom, replaceWith); @@ -494,7 +494,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string findAndReplace(result, "{line}", MathLib::toString(_callStack.back().line)); findAndReplace(result, "{column}", MathLib::toString(_callStack.back().col)); if (result.find("{code}") != std::string::npos) { - const std::string::size_type pos = result.find("\r"); + const std::string::size_type pos = result.find('\r'); const char *endl; if (pos == std::string::npos) endl = "\n"; @@ -525,7 +525,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string findAndReplace(text, "{column}", MathLib::toString(fileLocation.col)); findAndReplace(text, "{info}", fileLocation.getinfo().empty() ? mShortMessage : fileLocation.getinfo()); if (text.find("{code}") != std::string::npos) { - const std::string::size_type pos = text.find("\r"); + const std::string::size_type pos = text.find('\r'); const char *endl; if (pos == std::string::npos) endl = "\n"; diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 007abd6ff..57731f8c5 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -184,8 +184,8 @@ bool Suppressions::Suppression::parseComment(std::string comment, std::string *e if (comment.size() < 2) return false; - if (comment.find(";") != std::string::npos) - comment.erase(comment.find(";")); + if (comment.find(';') != std::string::npos) + comment.erase(comment.find(';')); if (comment.find("//", 2) != std::string::npos) comment.erase(comment.find("//",2));