From e6855210e0b408e1a5b2f9c366ab7ee95f396c2d Mon Sep 17 00:00:00 2001 From: mychoxin Date: Sat, 12 Aug 2017 16:48:20 +0800 Subject: [PATCH] os/bluestore: function collect_metadata, use 'const string&' to reduce copy Signed-off-by: mychoxin --- src/os/bluestore/BlockDevice.h | 2 +- src/os/bluestore/KernelDevice.cc | 2 +- src/os/bluestore/KernelDevice.h | 2 +- src/os/bluestore/NVMEDevice.cc | 2 +- src/os/bluestore/NVMEDevice.h | 2 +- src/os/bluestore/PMEMDevice.cc | 2 +- src/os/bluestore/PMEMDevice.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 0014c6863200..a90cedeb8543 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -115,7 +115,7 @@ public: uint64_t get_size() const { return size; } uint64_t get_block_size() const { return block_size; } - virtual int collect_metadata(std::string prefix, std::map *pm) const = 0; + virtual int collect_metadata(const std::string& prefix, std::map *pm) const = 0; virtual int read( uint64_t off, diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index b0a4cde589cc..1ed767333e7c 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -198,7 +198,7 @@ static string get_dev_property(const char *dev, const char *property) return val; } -int KernelDevice::collect_metadata(string prefix, map *pm) const +int KernelDevice::collect_metadata(const string& prefix, map *pm) const { (*pm)[prefix + "rotational"] = stringify((int)(bool)rotational); (*pm)[prefix + "size"] = stringify(get_size()); diff --git a/src/os/bluestore/KernelDevice.h b/src/os/bluestore/KernelDevice.h index 26e9c9a05192..e5a21a10a2e3 100644 --- a/src/os/bluestore/KernelDevice.h +++ b/src/os/bluestore/KernelDevice.h @@ -75,7 +75,7 @@ public: void aio_submit(IOContext *ioc) override; - int collect_metadata(std::string prefix, map *pm) const override; + int collect_metadata(const std::string& prefix, map *pm) const override; int read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc, diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 6c791dbf9973..2ff5dac33575 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -929,7 +929,7 @@ void NVMEDevice::close() dout(1) << __func__ << " end" << dendl; } -int NVMEDevice::collect_metadata(string prefix, map *pm) const +int NVMEDevice::collect_metadata(const string& prefix, map *pm) const { (*pm)[prefix + "rotational"] = "0"; (*pm)[prefix + "size"] = stringify(get_size()); diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index 4ce6b7ec5778..21ce0d91535f 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -227,7 +227,7 @@ class NVMEDevice : public BlockDevice { int invalidate_cache(uint64_t off, uint64_t len) override; int open(const string& path) override; void close() override; - int collect_metadata(string prefix, map *pm) const override; + int collect_metadata(const string& prefix, map *pm) const override; }; #endif diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 517870162a61..8b0494a64a9c 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -146,7 +146,7 @@ static string get_dev_property(const char *dev, const char *property) return val; } -int PMEMDevice::collect_metadata(string prefix, map *pm) const +int PMEMDevice::collect_metadata(const string& prefix, map *pm) const { (*pm)[prefix + "rotational"] = stringify((int)(bool)rotational); (*pm)[prefix + "size"] = stringify(get_size()); diff --git a/src/os/bluestore/PMEMDevice.h b/src/os/bluestore/PMEMDevice.h index ab3507192c88..d7dd248402cc 100644 --- a/src/os/bluestore/PMEMDevice.h +++ b/src/os/bluestore/PMEMDevice.h @@ -41,7 +41,7 @@ public: void aio_submit(IOContext *ioc) override; - int collect_metadata(std::string prefix, map *pm) const override; + int collect_metadata(const std::string& prefix, map *pm) const override; int read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc, -- 2.47.3