diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-04-01 14:55:37 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-04-01 14:55:37 +0000 |
commit | 1e89cdd6906be222e27871f620703d89e3edc370 (patch) | |
tree | d6182913899e41b2351d60c87ac83e8aab6c1d3b /searchcore | |
parent | 992de5d4c9d41813ab05183e7c646be249593340 (diff) |
Simplify with emplace and auto
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp index 8d93d6db6b3..3ced0f509b5 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketdb.cpp @@ -129,11 +129,8 @@ BucketDB::hasBucket(const BucketId &bucketId) const bool BucketDB::isActiveBucket(const BucketId &bucketId) const { - Map::const_iterator itr = _map.find(bucketId); - if (itr != _map.end()) { - return itr->second.isActive(); - } - return false; + auto itr = _map.find(bucketId); + return (itr != _map.end()) && itr->second.isActive(); } void @@ -187,7 +184,7 @@ BucketDB::createBucket(const BucketId &bucketId) void BucketDB::deleteEmptyBucket(const BucketId &bucketId) { - Map::iterator itr = _map.find(bucketId); + auto itr = _map.find(bucketId); if (itr == _map.end()) { return; } @@ -208,8 +205,7 @@ BucketDB::getActiveBuckets(BucketId::List &buckets) const } void -BucketDB::populateActiveBuckets(const BucketId::List &buckets, - BucketId::List &fixupBuckets) +BucketDB::populateActiveBuckets(const BucketId::List &buckets, BucketId::List &fixupBuckets) { typedef BucketId::List BIV; BIV sorted(buckets); @@ -233,7 +229,7 @@ BucketDB::populateActiveBuckets(const BucketId::List &buckets, BucketState activeState; activeState.setActive(true); for (const BucketId & bucketId : toAdd) { - InsertResult ins(_map.insert(std::make_pair(bucketId, activeState))); + InsertResult ins(_map.emplace(bucketId, activeState)); assert(ins.second); } } |