From a325a1c80ff208a2dc04f3d7d1cd320b88d10069 Mon Sep 17 00:00:00 2001 From: Ilya Maykov Date: Fri, 23 Jun 2017 11:32:32 -0700 Subject: [PATCH] move input shared_ptr in atomic_shared_ptr constructor Summary: By moving the input shared_ptr instead of copying it, we avoid doing an unnecessary ref count increment + decrement. Reviewed By: djwatson, yfeldblum Differential Revision: D5298467 fbshipit-source-id: b9f0b6999278609417bb4dc062030ca2388ba20a --- folly/experimental/AtomicSharedPtr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/folly/experimental/AtomicSharedPtr.h b/folly/experimental/AtomicSharedPtr.h index 6e4ef54a..7e8dce05 100644 --- a/folly/experimental/AtomicSharedPtr.h +++ b/folly/experimental/AtomicSharedPtr.h @@ -81,7 +81,7 @@ class atomic_shared_ptr { } explicit atomic_shared_ptr(SharedPtr foo) /* noexcept */ : atomic_shared_ptr() { - store(foo); + store(std::move(foo)); } atomic_shared_ptr(const atomic_shared_ptr&) = delete; @@ -89,7 +89,7 @@ class atomic_shared_ptr { store(SharedPtr(nullptr)); } void operator=(SharedPtr desired) /* noexcept */ { - store(desired); + store(std::move(desired)); } void operator=(const atomic_shared_ptr&) = delete; -- 2.34.1