Commit 4cc84128 authored by Praveen Kumar's avatar Praveen Kumar Committed by Andre Azevedo

We might avoid some temporaries

Summary:
It seems we might avoid temporaries.  To do so we pass arguments
directly to constructors with the help of emplace_back member.

Test Plan:
all folly/tests, make check for 37 tests, passed.

Closes https://github.com/facebook/folly/pull/150

Reviewed By: ldbrandy@fb.com

Subscribers: lins, anca, folly-diffs@, yfeldblum

FB internal diff: D1912505

Signature: t1:1912505:1426268158:086882bb53f3d79c3f3b7b2c362318f09b5ee3be
parent c2a60049
...@@ -264,8 +264,7 @@ void AsyncServerSocket::useExistingSockets(const std::vector<int>& fds) { ...@@ -264,8 +264,7 @@ void AsyncServerSocket::useExistingSockets(const std::vector<int>& fds) {
address.setFromLocalAddress(fd); address.setFromLocalAddress(fd);
setupSocket(fd); setupSocket(fd);
sockets_.push_back( sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
ServerEventHandler(eventBase_, fd, this, address.getFamily()));
sockets_.back().changeHandlerFD(fd); sockets_.back().changeHandlerFD(fd);
} }
} }
...@@ -292,8 +291,7 @@ void AsyncServerSocket::bindSocket( ...@@ -292,8 +291,7 @@ void AsyncServerSocket::bindSocket(
// If we just created this socket, update the EventHandler and set socket_ // If we just created this socket, update the EventHandler and set socket_
if (!isExistingSocket) { if (!isExistingSocket) {
sockets_.push_back( sockets_.emplace_back(eventBase_, fd, this, address.getFamily());
ServerEventHandler(eventBase_, fd, this, address.getFamily()));
} }
} }
...@@ -387,8 +385,7 @@ void AsyncServerSocket::bind(uint16_t port) { ...@@ -387,8 +385,7 @@ void AsyncServerSocket::bind(uint16_t port) {
SocketAddress address; SocketAddress address;
address.setFromLocalAddress(s); address.setFromLocalAddress(s);
sockets_.push_back( sockets_.emplace_back(eventBase_, s, this, address.getFamily());
ServerEventHandler(eventBase_, s, this, address.getFamily()));
// Bind to the socket // Bind to the socket
if (::bind(s, res->ai_addr, res->ai_addrlen) != 0) { if (::bind(s, res->ai_addr, res->ai_addrlen) != 0) {
...@@ -506,7 +503,7 @@ void AsyncServerSocket::addAcceptCallback(AcceptCallback *callback, ...@@ -506,7 +503,7 @@ void AsyncServerSocket::addAcceptCallback(AcceptCallback *callback,
eventBase = eventBase_; // Run in AsyncServerSocket's eventbase eventBase = eventBase_; // Run in AsyncServerSocket's eventbase
} }
callbacks_.push_back(CallbackInfo(callback, eventBase)); callbacks_.emplace_back(callback, eventBase);
// Start the remote acceptor. // Start the remote acceptor.
// //
......
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