cppcheck does not detect this inefficient way of removing last character of a std::string:
#include<string>std::stringfoo(std::strings){// Inefficient way of removing the last character of the string// as it creates and moves a temporary string.s=s.substr(0,s.size()-1);returns;}
It could suggest this instead which does not create a temporary string:
cppcheck does not detect this inefficient way of removing last character of a std::string:
It could suggest this instead which does not create a temporary string:
Last edit: Dominique Pelle 2022-07-08
Thanks! I have created: https://trac.cppcheck.net/ticket/11166