From: Phil Willoughby Date: Mon, 26 Jun 2017 14:08:25 +0000 (-0700) Subject: Improve efficiency of trivial toDelim calls X-Git-Tag: v2017.06.26.01~1 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2e7df7eb8df4df4e7dd7c2bc641c64b78405ecf4;p=folly.git 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 --- 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); } /**