diff options
author | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-02-13 14:51:28 +0100 |
---|---|---|
committer | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-02-13 14:51:28 +0100 |
commit | b0ec071a6db30b4ee407dee39916614b373d2978 (patch) | |
tree | 14ce54c84ce8b9760e13f6a53bb360acc55bbf92 /src/os | |
parent | monmaptool.cc: use empty() instead of size() to check for emptiness (diff) | |
download | ceph-b0ec071a6db30b4ee407dee39916614b373d2978.tar.xz ceph-b0ec071a6db30b4ee407dee39916614b373d2978.zip |
DBObjectMap.cc: use empty() instead of size() to check for emptiness
Use empty() since it should be prefered as it has, following the
standard, a constant time complexity regardless of the containter
type. The same is not guaranteed for size().
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/DBObjectMap.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/os/DBObjectMap.cc b/src/os/DBObjectMap.cc index f884266ff75..c3a4c3b9869 100644 --- a/src/os/DBObjectMap.cc +++ b/src/os/DBObjectMap.cc @@ -104,7 +104,7 @@ bool DBObjectMap::check(std::ostream &out) map<string, bufferlist> got; to_get.insert(HEADER_KEY); db->get(sys_parent_prefix(header), to_get, &got); - if (!got.size()) { + if (got.empty()) { out << "Missing: seq " << header.parent << std::endl; retval = false; break; @@ -553,7 +553,7 @@ int DBObjectMap::_get_header(Header header, set<string> to_get; to_get.insert(USER_HEADER_KEY); int r = db->get(sys_prefix(header), to_get, &out); - if (r == 0 && out.size()) + if (r == 0 && !out.empty()) break; if (r < 0) return r; @@ -563,7 +563,7 @@ int DBObjectMap::_get_header(Header header, header = lookup_parent(current); } - if (out.size()) + if (!out.empty()) bl->swap(out.begin()->second); return 0; } @@ -968,7 +968,7 @@ int DBObjectMap::upgrade() &got); if (r < 0) return r; - if (!got.size()) + if (got.empty()) continue; // Moved in a previous transaction t->rmkeys(USER_PREFIX + header_key(hdr.parent) + SYS_PREFIX, @@ -1016,7 +1016,7 @@ int DBObjectMap::init(bool do_upgrade) int r = db->get(SYS_PREFIX, to_get, &result); if (r < 0) return r; - if (result.size()) { + if (!result.empty()) { bufferlist::iterator bliter = result.begin()->second.begin(); state.decode(bliter); if (state.v < 1) { // Needs upgrade @@ -1080,7 +1080,7 @@ DBObjectMap::Header DBObjectMap::_lookup_map_header(const hobject_t &hoid) int r = db->get(HOBJECT_TO_SEQ, to_get, &out); if (r < 0) return Header(); - if (!out.size()) + if (out.empty()) return Header(); Header ret(new _Header(), RemoveMapHeaderOnDelete(this, hoid)); @@ -1123,7 +1123,7 @@ DBObjectMap::Header DBObjectMap::lookup_parent(Header input) assert(0); return Header(); } - if (out.size() < 1) { + if (out.empty()) { assert(0); return Header(); } |