From 36364d5f6b8193230182684dd1736bd83643ff2d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 6 Jun 2017 08:50:51 +0100 Subject: [PATCH] Fix spurious copies being made when using the format function We were not correctly forwarding the arguments, leading to copies of 'const String&' parameters. --- src/string.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/string.hh b/src/string.hh index cae9b170..056db814 100644 --- a/src/string.hh +++ b/src/string.hh @@ -418,17 +418,17 @@ StringView format_param(const T& val) { return val; } String format(StringView fmt, ArrayView params); template -String format(StringView fmt, Types... params) +String format(StringView fmt, Types&&... params) { - return format(fmt, ArrayView{detail::format_param(params)...}); + return format(fmt, ArrayView{detail::format_param(std::forward(params))...}); } StringView format_to(ArrayView buffer, StringView fmt, ArrayView params); template -StringView format_to(ArrayView buffer, StringView fmt, Types... params) +StringView format_to(ArrayView buffer, StringView fmt, Types&&... params) { - return format_to(buffer, fmt, ArrayView{detail::format_param(params)...}); + return format_to(buffer, fmt, ArrayView{detail::format_param(std::forward(params))...}); } }