diff options
author | Piotr Dałek <piotr.dalek@ts.fujitsu.com> | 2015-10-15 15:40:06 +0200 |
---|---|---|
committer | Sage Weil <sage@redhat.com> | 2015-10-19 18:57:23 +0200 |
commit | 709b111ceafe3893e82e3d576aa7b2d58bd16516 (patch) | |
tree | 78e2c72542b4d9e83f3da61ed08b720d13597901 /src/kv/KeyValueDB.h | |
parent | kv: move KeyValueDB from os/ to kv/, libos.a to libkv.a (diff) | |
download | ceph-709b111ceafe3893e82e3d576aa7b2d58bd16516.tar.xz ceph-709b111ceafe3893e82e3d576aa7b2d58bd16516.zip |
os/KeyValueDB: reduce malloc/free/string copy count
In RocksDB, LevelDB and Kinetic wrapper code, there is unnecessary
string copying. In particular, split_key makes an extra copy of string
(as a basis for extracted key and/or value), which can be easily omitted.
Also, checking for iterator validity generates std::pair with prefix
and key and checks prefix with the one from pair, wasting memory for
key.
Signed-off-by: Piotr Dałek <piotr.dalek@ts.fujitsu.com>
Diffstat (limited to 'src/kv/KeyValueDB.h')
-rw-r--r-- | src/kv/KeyValueDB.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h index 755a627f8f9..8691694ef3c 100644 --- a/src/kv/KeyValueDB.h +++ b/src/kv/KeyValueDB.h @@ -128,6 +128,7 @@ public: virtual int prev() = 0; virtual std::string key() = 0; virtual std::pair<std::string,std::string> raw_key() = 0; + virtual bool raw_key_is_prefixed(const std::string &prefix) = 0; virtual bufferlist value() = 0; virtual int status() = 0; virtual ~WholeSpaceIteratorImpl() { } @@ -157,8 +158,7 @@ public: bool valid() { if (!generic_iter->valid()) return false; - std::pair<std::string,std::string> raw_key = generic_iter->raw_key(); - return (raw_key.first.compare(0, prefix.length(), prefix) == 0); + return generic_iter->raw_key_is_prefixed(prefix); } int next() { if (valid()) |