From 61ecafd42604b32384aca1e4bd52fc59711f2f01 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 22 Jan 2019 23:04:47 -0800 Subject: [PATCH] Remove unnecessary string copies Found via clang-tidy. --- src/curl.cpp | 4 ++-- src/string_util.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/curl.cpp b/src/curl.cpp index 532539a..c2e24fa 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -4261,7 +4261,7 @@ string get_canonical_headers(const struct curl_slist* list) // skip empty-value headers (as they are discarded by libcurl) continue; } - strhead = strkey + string(":") + strval; + strhead = strkey.append(":").append(strval); }else{ strhead = trim(lower(strhead)); } @@ -4290,7 +4290,7 @@ string get_canonical_headers(const struct curl_slist* list, bool only_amz) // skip empty-value headers (as they are discarded by libcurl) continue; } - strhead = strkey + string(":") + strval; + strhead = strkey.append(":").append(strval); }else{ strhead = trim(lower(strhead)); } diff --git a/src/string_util.cpp b/src/string_util.cpp index 2bc5dd4..720feaa 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -120,8 +120,7 @@ string trim_right(const string &s, const string &t /* = SPACES */) string trim(const string &s, const string &t /* = SPACES */) { - string d(s); - return trim_left(trim_right(d, t), t); + return trim_left(trim_right(s, t), t); } /**