./cppcheck --enable=all test.cpp
Checking ../test.cpp... [../test.cpp:4]: (performance) Inefficient usage of string::find() in condition; string::compare() would be faster.
Is it intentional that now this checker is also used for find_first_of()?
Thanks,
Martin
Last edit: Martin 2016-01-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
since cppcheck1.72 the code
void main()
{
std::string firstChar = getName();
if (firstChar.find_first_of("0123456789") == 0)
return;
}
produces the finding
./cppcheck --enable=all test.cpp
Checking ../test.cpp...
[../test.cpp:4]: (performance) Inefficient usage of string::find() in condition; string::compare() would be faster.
Is it intentional that now this checker is also used for find_first_of()?
Thanks,
Martin
Last edit: Martin 2016-01-23
No that looks wrong as far as I see... can you please open a ticket in our issue tracker?
Well, you should certainly get a slap on the wrist for void main(), though. :p
Anyway, the issue is fixed for a few months already: http://trac.cppcheck.net/ticket/7349