File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -565,7 +565,8 @@ class HitSink {
565565 ThreadSafe _ts (&mutex_); // flush
566566 if (reorder_) {
567567 nchars += ptBufs_[threadId].length ();
568- batch b = {ptBufs_[threadId], batchIds_[threadId], false };
568+ batch b = { .batchId = batchIds_[threadId], .isWritten = false };
569+ ptBufs_[threadId].moveTo (b.btString );
569570 unwrittenBatches_.push_back (b);
570571 // consider writing if we have enough data to fill the buffer
571572 // or we're ready to output the final batch
@@ -634,10 +635,19 @@ class HitSink {
634635 size_t batchId;
635636 bool isWritten;
636637
637- bool operator < (const batch& other) const {
638+ bool operator <(const batch& other) const {
638639 return batchId < other.batchId ;
639640 }
640641
642+ batch& operator =(batch& other) {
643+ if (&other != *this ) {
644+ batchId = other.batchId ;
645+ isWritten = other.isWritten ;
646+ other.btString .moveTo (btString);
647+ }
648+ return *this ;
649+ }
650+
641651 static bool remove_written_batches (const batch& b) {
642652 return b.isWritten ;
643653 }
Original file line number Diff line number Diff line change @@ -2075,6 +2075,15 @@ class SStringExpandable {
20752075 */
20762076 T* wbuf () { return cs_; }
20772077
2078+ void moveTo (SStringExpandable<T,S>& o) {
2079+ if (&o != this ) {
2080+ o.sz_ = sz_; sz_ = 0 ;
2081+ o.cs_ = cs_; cs_ = NULL ;
2082+ o.len_ = len_; len_ = 0 ;
2083+ o.printcs_ = printcs_; printcs_ = NULL ;
2084+ }
2085+ }
2086+
20782087protected:
20792088 /* *
20802089 * Allocate new, bigger buffer and copy old contents into it. If
You can’t perform that action at this time.
0 commit comments