MB-17766: Avoid copy overhead of std::deque in getOutstandingItems 54/59754/2
authorabhinavdangeti <abhinav@couchbase.com>
Wed, 10 Feb 2016 18:03:03 +0000 (10:03 -0800)
committerabhinav dangeti <abhinav@couchbase.com>
Wed, 10 Feb 2016 19:05:25 +0000 (19:05 +0000)
Change-Id: I771182bd54a0f702f70287ff4728d26b7ffaa323
Reviewed-on: http://review.couchbase.org/59754
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/dcp-stream.cc
src/dcp-stream.h

index a687923..c487199 100644 (file)
@@ -690,7 +690,8 @@ void ActiveStreamCheckpointProcessorTask::schedule(stream_t stream) {
 void ActiveStream::nextCheckpointItemTask() {
     RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
     if (vbucket) {
-        std::deque<queued_item> items = getOutstandingItems(vbucket);
+        std::deque<queued_item> items;
+        getOutstandingItems(vbucket, items);
         processItems(items);
     } else {
         /* The entity deleting the vbucket must set stream to dead,
@@ -701,14 +702,12 @@ void ActiveStream::nextCheckpointItemTask() {
     }
 }
 
-std::deque<queued_item> ActiveStream::getOutstandingItems(RCPtr<VBucket> &vb) {
-    std::deque<queued_item> items;
+void ActiveStream::getOutstandingItems(RCPtr<VBucket> &vb,
+                                       std::deque<queued_item> &items) {
     vb->checkpointManager.getAllItemsForCursor(name_, items);
     if (vb->checkpointManager.getNumCheckpoints() > 1) {
         engine->getEpStore()->wakeUpCheckpointRemover();
     }
-
-    return items;
 }
 
 
index 97c0629..e63d4b7 100644 (file)
@@ -214,7 +214,7 @@ public:
 
 protected:
     // Returns the outstanding items for the stream's checkpoint cursor.
-    std::deque<queued_item> getOutstandingItems(RCPtr<VBucket> &vb);
+    void getOutstandingItems(RCPtr<VBucket> &vb, std::deque<queued_item> &items);
 
     // Given a set of queued items, create mutation responses for each item,
     // and pass onto the producer associated with this stream.