From ca09f73ca6bfe48f935e257143ea85b69fe43be8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 9 Mar 2021 22:30:56 +0800 Subject: [PATCH] crimson: pass by `const` or `const&` if possible more constness, and better performance. Signed-off-by: Kefu Chai --- src/crimson/os/seastore/cached_extent.cc | 2 +- .../os/seastore/omap_manager/btree/btree_omap_manager.cc | 2 +- .../os/seastore/omap_manager/btree/btree_omap_manager.h | 4 ++-- src/crimson/os/seastore/segment_manager/block.cc | 2 +- src/crimson/os/seastore/segment_manager/block.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crimson/os/seastore/cached_extent.cc b/src/crimson/os/seastore/cached_extent.cc index 7019b9fb802a4..d65d268db5691 100644 --- a/src/crimson/os/seastore/cached_extent.cc +++ b/src/crimson/os/seastore/cached_extent.cc @@ -86,7 +86,7 @@ std::ostream &operator<<(std::ostream &out, const lba_pin_list_t &rhs) { bool first = true; out << '['; - for (auto &i: rhs) { + for (const auto &i: rhs) { out << (first ? "" : ",") << *i; first = false; } diff --git a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc index 75b8f30b385f0..8f9069222deb4 100644 --- a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc +++ b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc @@ -48,7 +48,7 @@ BtreeOMapManager::handle_root_split_ret BtreeOMapManager::handle_root_split( omap_context_t oc, omap_root_t &omap_root, - OMapNode::mutation_result_t mresult) + const OMapNode::mutation_result_t& mresult) { return oc.tm.alloc_extent(oc.t, L_ADDR_MIN, OMAP_BLOCK_SIZE) .safe_then([&omap_root, mresult](auto&& nroot) -> handle_root_split_ret { diff --git a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h index 6762bdd661b09..48d4a9ec27ff3 100644 --- a/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h +++ b/src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.h @@ -36,7 +36,7 @@ class BtreeOMapManager : public OMapManager { */ using get_root_ertr = base_ertr; using get_root_ret = get_root_ertr::future; - get_root_ret get_omap_root( + static get_root_ret get_omap_root( omap_context_t c, const omap_root_t &omap_root); @@ -49,7 +49,7 @@ class BtreeOMapManager : public OMapManager { handle_root_split_ret handle_root_split( omap_context_t c, omap_root_t &omap_root, - OMapNode::mutation_result_t mresult); + const OMapNode::mutation_result_t& mresult); /* handle_root_merge * diff --git a/src/crimson/os/seastore/segment_manager/block.cc b/src/crimson/os/seastore/segment_manager/block.cc index 6a4991d42082f..9529ac6eb8757 100644 --- a/src/crimson/os/seastore/segment_manager/block.cc +++ b/src/crimson/os/seastore/segment_manager/block.cc @@ -256,7 +256,7 @@ BlockSegmentManager::~BlockSegmentManager() { } -BlockSegmentManager::mount_ret BlockSegmentManager::mount(mount_config_t config) +BlockSegmentManager::mount_ret BlockSegmentManager::mount(const mount_config_t& config) { return open_device( config.path, seastar::open_flags::rw | seastar::open_flags::dsync diff --git a/src/crimson/os/seastore/segment_manager/block.h b/src/crimson/os/seastore/segment_manager/block.h index 927b13e4e94b5..bfa4bd7e1926e 100644 --- a/src/crimson/os/seastore/segment_manager/block.h +++ b/src/crimson/os/seastore/segment_manager/block.h @@ -143,7 +143,7 @@ public: }; using mount_ertr = access_ertr; using mount_ret = access_ertr::future<>; - mount_ret mount(mount_config_t); + mount_ret mount(const mount_config_t&); struct mkfs_config_t { std::string path; -- 2.39.5