From 2e7df7eb8df4df4e7dd7c2bc641c64b78405ecf4 Mon Sep 17 00:00:00 2001 From: Phil Willoughby Date: Mon, 26 Jun 2017 07:08:25 -0700 Subject: [PATCH] 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 --- folly/Conv.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/folly/Conv.h b/folly/Conv.h index 6cc32705..72518d80 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -986,11 +986,12 @@ to(Src value) { * toDelim(SomeString str) returns itself. */ template -typename std::enable_if::value && - std::is_same::value, - Tgt>::type -toDelim(const Delim& /* delim */, const Src& value) { - return value; +typename std::enable_if< + IsSomeString::value && + std::is_same::type>::value, + Tgt>::type +toDelim(const Delim& /* delim */, Src&& value) { + return std::forward(value); } /** -- 2.34.1