From 8272cd9deca99b84fe18cddd561f24bb69249b57 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 12 Dec 2022 12:36:19 +0100 Subject: Optimize string concatenation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> --- src/libutil/util.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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; } -- cgit v1.2.3