From: Ilya Maykov Date: Fri, 23 Jun 2017 18:32:32 +0000 (-0700) Subject: move input shared_ptr in atomic_shared_ptr constructor X-Git-Tag: v2017.06.26.00~9 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a325a1c80ff208a2dc04f3d7d1cd320b88d10069;p=folly.git 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 --- 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;