Commit a325a1c8 authored by Ilya Maykov's avatar Ilya Maykov Committed by Facebook Github Bot

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
parent 297d72d1
...@@ -81,7 +81,7 @@ class atomic_shared_ptr { ...@@ -81,7 +81,7 @@ class atomic_shared_ptr {
} }
explicit atomic_shared_ptr(SharedPtr foo) /* noexcept */ explicit atomic_shared_ptr(SharedPtr foo) /* noexcept */
: atomic_shared_ptr() { : atomic_shared_ptr() {
store(foo); store(std::move(foo));
} }
atomic_shared_ptr(const atomic_shared_ptr<T>&) = delete; atomic_shared_ptr(const atomic_shared_ptr<T>&) = delete;
...@@ -89,7 +89,7 @@ class atomic_shared_ptr { ...@@ -89,7 +89,7 @@ class atomic_shared_ptr {
store(SharedPtr(nullptr)); store(SharedPtr(nullptr));
} }
void operator=(SharedPtr desired) /* noexcept */ { void operator=(SharedPtr desired) /* noexcept */ {
store(desired); store(std::move(desired));
} }
void operator=(const atomic_shared_ptr<T>&) = delete; void operator=(const atomic_shared_ptr<T>&) = delete;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment