Commit 2e7df7eb authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

Improve efficiency of trivial toDelim calls

Summary:
`toDelim` with a single parameter of the same type as the target type was
previously copy-constructing its result. It will now construct it with perfect
forwarding which is more efficient if the input is a temporary.

This brings `toDelim` into line with the similar implementations of `to` and
`tryTo`

Reviewed By: yfeldblum

Differential Revision: D5301427

fbshipit-source-id: 843a2d93384de88cce42f26da6562a1a6ed0dc9c
parent cf8a8e02
......@@ -986,11 +986,12 @@ to(Src value) {
* toDelim<SomeString>(SomeString str) returns itself.
*/
template <class Tgt, class Delim, class Src>
typename std::enable_if<IsSomeString<Tgt>::value &&
std::is_same<Tgt, Src>::value,
Tgt>::type
toDelim(const Delim& /* delim */, const Src& value) {
return value;
typename std::enable_if<
IsSomeString<Tgt>::value &&
std::is_same<Tgt, typename std::decay<Src>::type>::value,
Tgt>::type
toDelim(const Delim& /* delim */, Src&& value) {
return std::forward<Src>(value);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment