Merge pull request #1059 from kwkam/patch-3

replace some lines with make_shared
This commit is contained in:
Tatsuhiro Tsujikawa 2017-11-05 16:02:14 +09:00 committed by GitHub
commit 8f5eaa4bbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 14 deletions

View File

@ -115,7 +115,7 @@ public:
void findAll(OutputIterator out, const std::string& hostname,
uint16_t port) const
{
std::shared_ptr<CacheEntry> target(new CacheEntry(hostname, port));
auto target = std::make_shared<CacheEntry>(hostname, port);
auto i = entries_.find(target);
if (i != entries_.end()) {
(*i)->getAllGoodAddrs(out);

View File

@ -49,13 +49,11 @@ struct HttpRequestConnectChain : public ControlChain<ConnectCommand*> {
virtual ~HttpRequestConnectChain() {}
virtual int run(ConnectCommand* t, DownloadEngine* e) CXX11_OVERRIDE
{
std::shared_ptr<SocketRecvBuffer> socketRecvBuffer(
new SocketRecvBuffer(t->getSocket()));
std::shared_ptr<HttpConnection> httpConnection(
new HttpConnection(t->getCuid(), t->getSocket(), socketRecvBuffer));
auto b = std::make_shared<SocketRecvBuffer>(t->getSocket());
auto k = std::make_shared<HttpConnection>(t->getCuid(), t->getSocket(), b);
auto c = make_unique<HttpRequestCommand>(
t->getCuid(), t->getRequest(), t->getFileEntry(), t->getRequestGroup(),
httpConnection, e, t->getSocket());
k, e, t->getSocket());
c->setProxyRequest(t->getProxyRequest());
c->setStatus(Command::STATUS_ONESHOT_REALTIME);
e->setNoWait(true);

View File

@ -168,7 +168,7 @@ int translateEvents(EventPoll::EventType events)
bool PortEventPoll::addEvents(sock_t socket, const PortEventPoll::KEvent& event)
{
std::shared_ptr<KSocketEntry> socketEntry(new KSocketEntry(socket));
auto socketEntry = std::make_shared<KSocketEntry>(socket);
KSocketEntrySet::iterator i = socketEntries_.lower_bound(socketEntry);
int r = 0;
int errNum = 0;
@ -220,7 +220,7 @@ bool PortEventPoll::addEvents(sock_t socket, Command* command, int events,
bool PortEventPoll::deleteEvents(sock_t socket,
const PortEventPoll::KEvent& event)
{
std::shared_ptr<KSocketEntry> socketEntry(new KSocketEntry(socket));
auto socketEntry = std::make_shared<KSocketEntry>(socket);
KSocketEntrySet::iterator i = socketEntries_.find(socketEntry);
if (i == socketEntries_.end()) {
A2_LOG_DEBUG(fmt("Socket %d is not found in SocketEntries.", socket));
@ -271,8 +271,7 @@ bool PortEventPoll::deleteEvents(sock_t socket, Command* command,
bool PortEventPoll::addNameResolver(
const std::shared_ptr<AsyncNameResolver>& resolver, Command* command)
{
std::shared_ptr<KAsyncNameResolverEntry> entry(
new KAsyncNameResolverEntry(resolver, command));
auto entry = std::make_shared<KAsyncNameResolverEntry>(resolver, command);
KAsyncNameResolverEntrySet::iterator itr = nameResolverEntries_.find(entry);
if (itr == nameResolverEntries_.end()) {
nameResolverEntries_.insert(entry);
@ -287,8 +286,7 @@ bool PortEventPoll::addNameResolver(
bool PortEventPoll::deleteNameResolver(
const std::shared_ptr<AsyncNameResolver>& resolver, Command* command)
{
std::shared_ptr<KAsyncNameResolverEntry> entry(
new KAsyncNameResolverEntry(resolver, command));
auto entry = std::make_shared<KAsyncNameResolverEntry>(resolver, command);
KAsyncNameResolverEntrySet::iterator itr = nameResolverEntries_.find(entry);
if (itr == nameResolverEntries_.end()) {
return false;

View File

@ -55,8 +55,8 @@ WebSocketResponseCommand::~WebSocketResponseCommand() = default;
void WebSocketResponseCommand::afterSend(
const std::shared_ptr<HttpServer>& httpServer, DownloadEngine* e)
{
std::shared_ptr<WebSocketSession> wsSession(
new WebSocketSession(httpServer->getSocket(), getDownloadEngine()));
auto wsSession = std::make_shared<WebSocketSession>(
httpServer->getSocket(), getDownloadEngine());
auto command = make_unique<WebSocketInteractionCommand>(
getCuid(), wsSession, e, wsSession->getSocket());
wsSession->setCommand(command.get());