Rephraze performance message. /would be faster/could be faster/ to indicate that Cppcheck is not _sure_ that it would be faster
This commit is contained in:
parent
40600cbc38
commit
90a215af0e
|
@ -1228,7 +1228,7 @@ void CheckStl::if_findError(const Token *tok, bool str)
|
|||
{
|
||||
if (str && mSettings->standards.cpp >= Standards::CPP20)
|
||||
reportError(tok, Severity::performance, "stlIfStrFind",
|
||||
"Inefficient usage of string::find() in condition; string::starts_with() would be faster.\n"
|
||||
"Inefficient usage of string::find() in condition; string::starts_with() could be faster.\n"
|
||||
"Either inefficient or wrong usage of string::find(). string::starts_with() will be faster if "
|
||||
"string::find's result is compared with 0, because it will not scan the whole "
|
||||
"string. If your intention is to check that there are no findings in the string, "
|
||||
|
|
|
@ -2391,35 +2391,35 @@ private:
|
|||
"{\n"
|
||||
" if (s.find(\"abc\")) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() would be faster.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() could be faster.\n", errout.str());
|
||||
|
||||
// error (pointer)
|
||||
check("void f(const std::string *s)\n"
|
||||
"{\n"
|
||||
" if ((*s).find(\"abc\")) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() would be faster.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() could be faster.\n", errout.str());
|
||||
|
||||
// error (pointer)
|
||||
check("void f(const std::string *s)\n"
|
||||
"{\n"
|
||||
" if (s->find(\"abc\")) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() would be faster.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() could be faster.\n", errout.str());
|
||||
|
||||
// error (vector)
|
||||
check("void f(const std::vector<std::string> &s)\n"
|
||||
"{\n"
|
||||
" if (s[0].find(\"abc\")) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() would be faster.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() could be faster.\n", errout.str());
|
||||
|
||||
// #3162
|
||||
check("void f(const std::string& s1, const std::string& s2)\n"
|
||||
"{\n"
|
||||
" if ((!s1.empty()) && (0 == s1.find(s2))) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() would be faster.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (performance) Inefficient usage of string::find() in condition; string::starts_with() could be faster.\n", errout.str());
|
||||
|
||||
// #4102
|
||||
check("void f(const std::string &define) {\n"
|
||||
|
|
Loading…
Reference in New Issue