Optimize string concatenation

Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
This commit is contained in:
Eelco Dolstra 2022-12-12 12:36:19 +01:00 committed by GitHub
parent 703d863a48
commit 8272cd9dec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -756,7 +756,9 @@ inline std::string operator + (std::string && s, std::string_view s2)
inline std::string operator + (std::string_view s1, const char * s2)
{
std::string s(s1);
std::string s;
s.reserve(s1.size() + strlen(s2));
s.append(s1);
s.append(s2);
return s;
}