File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -81,24 +81,24 @@ void CapturingReplyBuilder::SendDirect(Payload&& val) {
81
81
}
82
82
}
83
83
84
- void CapturingReplyBuilder::Capture (Payload val) {
84
+ void CapturingReplyBuilder::Capture (Payload val, bool collapse_if_needed ) {
85
85
if (!stack_.empty ()) {
86
- stack_.top ().first ->arr .push_back (std::move (val));
87
- stack_.top ().second --;
86
+ auto & last = stack_.top ();
87
+ last.first ->arr .push_back (std::move (val));
88
+ if (collapse_if_needed && last.second -- == 1 ) {
89
+ CollapseFilledCollections ();
90
+ }
88
91
} else {
89
92
DCHECK_EQ (current_.index (), 0u );
90
93
current_ = std::move (val);
91
94
}
92
-
93
- // Check if we filled up a collection.
94
- CollapseFilledCollections ();
95
95
}
96
96
97
97
void CapturingReplyBuilder::CollapseFilledCollections () {
98
98
while (!stack_.empty () && stack_.top ().second == 0 ) {
99
99
auto pl = std::move (stack_.top ());
100
100
stack_.pop ();
101
- Capture (std::move (pl.first ));
101
+ Capture (std::move (pl.first ), false );
102
102
}
103
103
}
104
104
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ class CapturingReplyBuilder : public RedisReplyBuilder {
79
79
void SendDirect (Payload&& val);
80
80
81
81
// Capture value and store eiter in current topmost collection or as a standalone value.
82
- void Capture (Payload val);
82
+ void Capture (Payload val, bool collapse_if_needed = true );
83
83
84
84
// While topmost collection in stack is full, finalize it and add it as a regular value.
85
85
void CollapseFilledCollections ();
You can’t perform that action at this time.
0 commit comments