diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-12-12 12:36:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-12 12:36:19 +0100 |
commit | 8272cd9deca99b84fe18cddd561f24bb69249b57 (patch) | |
tree | ecf247b3b803ae6fcdd828b7f73ff95919425074 /src | |
parent | 703d863a48f549b2626382eda407ffae779f8725 (diff) |
Optimize string concatenation
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/util.hh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 3caa95fca..2f869d909 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -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; } |