]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move ShardTracker::next_candidate() into lamdba 33628/head
authorCasey Bodley <cbodley@redhat.com>
Fri, 28 Feb 2020 18:58:53 +0000 (13:58 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 28 Feb 2020 18:58:53 +0000 (13:58 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rados.cc

index 416a952b23326b93d78e974f04af9755a29f1d77..3b83ffc8b1c5bf0099dbaf29fa136aa8fe66d7aa 100644 (file)
@@ -8281,18 +8281,19 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info,
     inline bool at_end() const {
       return cursor == end;
     }
-    // add the next unique candidate, or return false if we reach the end
-    bool next_candidate(std::map<std::string, size_t>& candidates,
-                        size_t tracker_idx) {
-      while (!at_end()) {
-        if (candidates.emplace(entry_name(), tracker_idx).second) {
-          return true;
-        }
-        advance(); // skip duplicate common prefixes
+  }; // ShardTracker
+
+  // add the next unique candidate, or return false if we reach the end
+  auto next_candidate = [] (ShardTracker& t,
+                            std::map<std::string, size_t>& candidates,
+                            size_t tracker_idx) {
+    while (!t.at_end()) {
+      if (candidates.emplace(t.entry_name(), tracker_idx).second) {
+        return;
       }
-      return false;
+      t.advance(); // skip duplicate common prefixes
     }
-  }; // ShardTracker
+  };
 
   // one tracker per shard requested (may not be all shards)
   std::vector<ShardTracker> results_trackers;
@@ -8319,7 +8320,7 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info,
     // it's important that the values in the map refer to the index
     // into the results_trackers vector, which may not be the same
     // as the shard number (i.e., when not all shards are requested)
-    t.next_candidate(candidates, tracker_idx);
+    next_candidate(t, candidates, tracker_idx);
     ++tracker_idx;
   }
 
@@ -8376,9 +8377,10 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info,
     // refresh the candidates map
     candidates.erase(candidates.begin());
     tracker.advance();
-    if (tracker.next_candidate(candidates, tracker_idx)) {
-      // we got a candidate, so we're not at the end yet
-    } else if (tracker.is_truncated()) {
+
+    next_candidate(tracker, candidates, tracker_idx);
+
+    if (tracker.at_end() && tracker.is_truncated()) {
       // once we exhaust one shard that is truncated, we need to stop,
       // as we cannot be certain that one of the next entries needs to
       // come from that shard; S3 and swift protocols allow returning