Improve folly::RequestContext::get()
authorTeng Qin <qinteng@fb.com>
Tue, 31 Oct 2017 20:49:14 +0000 (13:49 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 31 Oct 2017 20:54:54 +0000 (13:54 -0700)
Summary:
Since `folly::RequestContext::get()` returns raw pointer, it could directly use the reference returned by `getStaticContext()`
I don't expect this to make much of a difference, just tiny improvements

Reviewed By: yfeldblum

Differential Revision: D6153353

fbshipit-source-id: 1c41d4fc259aa5cb3e69e50ed24bed1ba9caf6c3

folly/io/async/Request.cpp

index aff3fa6..b1dd0f7 100644 (file)
@@ -123,7 +123,7 @@ std::shared_ptr<RequestContext>& RequestContext::getStaticContext() {
 }
 
 RequestContext* RequestContext::get() {
-  auto context = getStaticContext();
+  auto& context = getStaticContext();
   if (!context) {
     static RequestContext defaultContext;
     return std::addressof(defaultContext);