Commit 28fd04bd authored by Mikhail Shatalov's avatar Mikhail Shatalov Committed by Facebook GitHub Bot

Avoid shared_ptr copy in EventBaseLocal::getOrCreate

Summary: `folly::get_default()` returns a copy of shared_ptr that gets immediately discarded. The change avoids that.

Reviewed By: yfeldblum

Differential Revision: D22119215

fbshipit-source-id: 36aab580d7042d19b6b076cad20586697fbfa5e3
parent d0b905b1
......@@ -35,7 +35,8 @@ EventBaseLocalBase::~EventBaseLocalBase() {
void* EventBaseLocalBase::getVoid(EventBase& evb) {
evb.dcheckIsInEventBaseThread();
return folly::get_default(evb.localStorage_, key_, {}).get();
auto ptr = folly::get_ptr(evb.localStorage_, key_);
return ptr ? ptr->get() : nullptr;
}
void EventBaseLocalBase::erase(EventBase& evb) {
......
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