I have been looking into providing helper for efficient string concatenation in danmar/cppcheck#8344.
I initially had the following for char.
#include <string>
void concat1(std::string& str, char c)
{
str.append(1, c);
}
Turns out that is less efficient then either of the following (which behave exactly the same):
void concat2(std::string& str, char c)
{
str += c;
}
void concat3(std::string& str, char c)
{
str.push_back(c);
}
https://godbolt.org/z/1P4E7Wdcc
I have been looking into providing helper for efficient string concatenation in danmar/cppcheck#8344.
I initially had the following for
char.Turns out that is less efficient then either of the following (which behave exactly the same):
https://godbolt.org/z/1P4E7Wdcc