Minor optimize copying of shared_ptr in IBSocket and StorageTargets (#56)

This commit is contained in:
mwish
2025-03-03 16:16:17 +08:00
committed by GitHub
parent f05d2bf8a7
commit fcb915b050
3 changed files with 5 additions and 5 deletions

View File

@@ -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{};
}
@@ -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{};
}
@@ -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{};
}