Skip to content

Commit

Permalink
Minor optimize copying of shared_ptr in IBSocket and StorageTargets (#56
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mapleFU authored Mar 3, 2025
1 parent f05d2bf commit fcb915b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/common/net/ib/IBSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ IBSocket::Drainer::Ptr IBSocket::Drainer::create(IBSocket::Ptr socket, std::weak

IBSocket::Drainer::Drainer(IBSocket::Ptr socket, std::weak_ptr<IBSocketManager> manager)
: socket_(std::move(socket)),
manager_(manager) {
manager_(std::move(manager)) {
draining.addSample(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/net/ib/IBSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ class IBSocketManager : public EventLoop::EventHandler, public std::enable_share

private:
friend class IBSocket::Drainer;
void remove(IBSocket::Drainer::Ptr drainer) { drainers_.lock()->erase(drainer); }
void remove(const IBSocket::Drainer::Ptr &drainer) { drainers_.lock()->erase(drainer); }

FdWrapper timer_;
folly::Synchronized<std::set<IBSocket::Drainer::Ptr>, std::mutex> drainers_;
Expand Down
6 changes: 3 additions & 3 deletions src/storage/store/StorageTargets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Result<Void> StorageTargets::create(const CreateConfig &createConfig) {
targetConfig.only_chunk_engine = createConfig.only_chunk_engine();
RETURN_AND_LOG_ON_ERROR(storageTarget->create(targetConfig));
++idx;
RETURN_AND_LOG_ON_ERROR(targetMap_.addStorageTarget(storageTarget));
RETURN_AND_LOG_ON_ERROR(targetMap_.addStorageTarget(std::move(storageTarget)));
}
return Void{};
}
Expand Down Expand Up @@ -189,7 +189,7 @@ Result<Void> StorageTargets::create(const CreateTargetReq &req) {
targetConfig.only_chunk_engine = req.onlyChunkEngine;
RETURN_AND_LOG_ON_ERROR(storageTarget->create(targetConfig));
XLOGF(INFO, "Create storage target {} at {}", storageTarget->targetId(), targetPath.string());
RETURN_AND_LOG_ON_ERROR(targetMap_.addStorageTarget(storageTarget));
RETURN_AND_LOG_ON_ERROR(targetMap_.addStorageTarget(std::move(storageTarget)));
return Void{};
}

Expand Down Expand Up @@ -242,7 +242,7 @@ Result<Void> StorageTargets::loadTarget(const Path &targetPath) {
XLOG(ERR, msg);
return makeError(StorageCode::kStorageInitFailed, std::move(msg));
}
RETURN_AND_LOG_ON_ERROR(targetMap_.addStorageTarget(storageTarget));
RETURN_AND_LOG_ON_ERROR(targetMap_.addStorageTarget(std::move(storageTarget)));
return Void{};
}

Expand Down

0 comments on commit fcb915b

Please sign in to comment.