Fix spurious copies being made when using the format function
We were not correctly forwarding the arguments, leading to copies of 'const String&' parameters.
This commit is contained in:
parent
8794687f36
commit
36364d5f6b
|
@ -418,17 +418,17 @@ StringView format_param(const T& val) { return val; }
|
||||||
String format(StringView fmt, ArrayView<const StringView> params);
|
String format(StringView fmt, ArrayView<const StringView> params);
|
||||||
|
|
||||||
template<typename... Types>
|
template<typename... Types>
|
||||||
String format(StringView fmt, Types... params)
|
String format(StringView fmt, Types&&... params)
|
||||||
{
|
{
|
||||||
return format(fmt, ArrayView<const StringView>{detail::format_param(params)...});
|
return format(fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...});
|
||||||
}
|
}
|
||||||
|
|
||||||
StringView format_to(ArrayView<char> buffer, StringView fmt, ArrayView<const StringView> params);
|
StringView format_to(ArrayView<char> buffer, StringView fmt, ArrayView<const StringView> params);
|
||||||
|
|
||||||
template<typename... Types>
|
template<typename... Types>
|
||||||
StringView format_to(ArrayView<char> buffer, StringView fmt, Types... params)
|
StringView format_to(ArrayView<char> buffer, StringView fmt, Types&&... params)
|
||||||
{
|
{
|
||||||
return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(params)...});
|
return format_to(buffer, fmt, ArrayView<const StringView>{detail::format_param(std::forward<Types>(params))...});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user