From: Sage Weil Date: Tue, 24 Sep 2019 13:30:17 +0000 (-0500) Subject: mon/MonitorDBStore: use const string& for args throughout X-Git-Tag: v15.1.0~1398^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d4fdd5a1e667338d6bde0ca8d66e8432ddfddfdd;p=ceph.git mon/MonitorDBStore: use const string& for args throughout const bufferlist& too Signed-off-by: Sage Weil --- diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 4f84654b65c..d7782de9890 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -69,11 +69,11 @@ class MonitorDBStore Op() : type(0) { } - Op(int t, string p, string k) + Op(int t, const string& p, const string& k) : type(t), prefix(p), key(k) { } - Op(int t, const string& p, string k, bufferlist& b) + Op(int t, const string& p, const string& k, const bufferlist& b) : type(t), prefix(p), key(k), bl(b) { } - Op(int t, const string& p, string start, string end) + Op(int t, const string& p, const string& start, const string& end) : type(t), prefix(p), key(start), endkey(end) { } void encode(bufferlist& encode_bl) const { @@ -101,8 +101,9 @@ class MonitorDBStore f->dump_int("type", type); f->dump_string("prefix", prefix); f->dump_string("key", key); - if (endkey.length()) + if (endkey.length()) { f->dump_string("endkey", endkey); + } } static void generate_test_instances(list& ls) { @@ -126,48 +127,50 @@ class MonitorDBStore OP_ERASE_RANGE = 4, }; - void put(string prefix, string key, bufferlist& bl) { + void put(const string& prefix, const string& key, const bufferlist& bl) { ops.push_back(Op(OP_PUT, prefix, key, bl)); ++keys; bytes += prefix.length() + key.length() + bl.length(); } - void put(string prefix, version_t ver, bufferlist& bl) { + void put(const string& prefix, version_t ver, const bufferlist& bl) { ostringstream os; os << ver; put(prefix, os.str(), bl); } - void put(string prefix, string key, version_t ver) { + void put(const string& prefix, const string& key, version_t ver) { using ceph::encode; bufferlist bl; encode(ver, bl); put(prefix, key, bl); } - void erase(string prefix, string key) { + void erase(const string& prefix, const string& key) { ops.push_back(Op(OP_ERASE, prefix, key)); ++keys; bytes += prefix.length() + key.length(); } - void erase(string prefix, version_t ver) { + void erase(const string& prefix, version_t ver) { ostringstream os; os << ver; erase(prefix, os.str()); } - void erase_range(string prefix, string begin, string end) { + void erase_range(const string& prefix, const string& begin, + const string& end) { ops.push_back(Op(OP_ERASE_RANGE, prefix, begin, end)); ++keys; bytes += prefix.length() + begin.length() + end.length(); } - void compact_prefix(string prefix) { + void compact_prefix(const string& prefix) { ops.push_back(Op(OP_COMPACT, prefix, string())); } - void compact_range(string prefix, string start, string end) { + void compact_range(const string& prefix, const string& start, + const string& end) { ops.push_back(Op(OP_COMPACT, prefix, start, end)); } @@ -405,8 +408,8 @@ class MonitorDBStore virtual ~StoreIteratorImpl() { } bool add_chunk_entry(TransactionRef tx, - string &prefix, - string &key, + const string &prefix, + const string &key, bufferlist &value, uint64_t max) { auto tmp(std::make_shared()); @@ -614,7 +617,7 @@ class MonitorDBStore ceph_assert(r >= 0); } - void _open(string kv_type) { + void _open(const string& kv_type) { string::const_reverse_iterator rit; int pos = 0; for (rit = path.rbegin(); rit != path.rend(); ++rit, ++pos) {