From: Nicholas Ormrod <njormrod@fb.com>
Date: Thu, 16 Apr 2015 20:42:45 +0000 (-0700)
Subject: We might avoid some temporaries in putMessagesImpl
X-Git-Tag: v0.36.0~32
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0011d8a0631c54b05cd40f35f47b181109165e52;p=folly.git

We might avoid some temporaries in putMessagesImpl

Summary:
This is folly github pull request https://github.com/facebook/folly/pull/184

It seems we might avoid some temporaries in putMessagesImpl
function. To do so we pass arguments directly to constructors
with the help of emplace_back member.

Test Plan:
All folly/tests, make check for 37 tests, passed.

Signed-off-by: Nicholas Ormrod <njormrod@fb.com>

Reviewed By: davejwatson@fb.com

Subscribers: folly-diffs@, yfeldblum, chalfant

FB internal diff: D1998515

Tasks: 6783581

Signature: t1:1998515:1429207683:056db129405bed212f50a50821f095c8d3694ec8
---

diff --git a/folly/io/async/NotificationQueue.h b/folly/io/async/NotificationQueue.h
index 95c85160..cbbed8c4 100644
--- a/folly/io/async/NotificationQueue.h
+++ b/folly/io/async/NotificationQueue.h
@@ -514,9 +514,7 @@ class NotificationQueue {
       if (numActiveConsumers_ < numConsumers_) {
         signal = true;
       }
-      queue_.push_back(
-        std::make_pair(std::move(message),
-                       RequestContext::saveContext()));
+      queue_.emplace_back(std::move(message), RequestContext::saveContext());
     }
     if (signal) {
       signalEvent();
@@ -536,7 +534,7 @@ class NotificationQueue {
       if (numActiveConsumers_ < numConsumers_) {
         signal = true;
       }
-      queue_.push_back(std::make_pair(message, RequestContext::saveContext()));
+      queue_.emplace_back(message, RequestContext::saveContext());
     }
     if (signal) {
       signalEvent();
@@ -554,7 +552,7 @@ class NotificationQueue {
       folly::SpinLockGuard g(spinlock_);
       checkDraining();
       while (first != last) {
-        queue_.push_back(std::make_pair(*first, RequestContext::saveContext()));
+        queue_.emplace_back(*first, RequestContext::saveContext());
         ++first;
         ++numAdded;
       }