@@ -6,10 +6,14 @@ namespace NYql {
6
6
7
7
TChunkedBuffer::TChunkedBuffer (TChunkedBuffer&& other) {
8
8
Items_ = std::move (other.Items_ );
9
+ Size_ = other.Size_ ;
10
+ other.Size_ = 0 ;
9
11
}
10
12
11
13
TChunkedBuffer& TChunkedBuffer::operator =(TChunkedBuffer&& other) {
12
14
Items_ = std::move (other.Items_ );
15
+ Size_ = other.Size_ ;
16
+ other.Size_ = 0 ;
13
17
return *this ;
14
18
}
15
19
@@ -40,25 +44,10 @@ size_t TChunkedBuffer::CopyTo(IOutputStream& dst, size_t toCopy) const {
40
44
return copied;
41
45
}
42
46
43
- size_t TChunkedBuffer::ContigousSize () const {
44
- return Items_.empty () ? 0 : Front ().Buf .size ();
45
- }
46
-
47
- size_t TChunkedBuffer::Size () const {
48
- size_t result = 0 ;
49
- for (auto & item : Items_) {
50
- result += item.Buf .size ();
51
- }
52
- return result;
53
- }
54
-
55
- bool TChunkedBuffer::Empty () const {
56
- return Items_.empty ();
57
- }
58
-
59
47
TChunkedBuffer& TChunkedBuffer::Append (TStringBuf buf, const std::shared_ptr<const void >& owner) {
60
48
if (!buf.empty ()) {
61
49
Items_.emplace_back (TChunk{buf, owner});
50
+ Size_ += buf.size ();
62
51
}
63
52
return *this ;
64
53
}
@@ -67,20 +56,24 @@ TChunkedBuffer& TChunkedBuffer::Append(TString&& str) {
67
56
if (!str.empty ()) {
68
57
auto owner = std::make_shared<TString>(std::move (str));
69
58
Items_.emplace_back (TChunk{*owner, owner});
59
+ Size_ += owner->size ();
70
60
}
71
61
return *this ;
72
62
}
73
63
74
64
TChunkedBuffer& TChunkedBuffer::Append (TChunkedBuffer&& other) {
75
65
while (!other.Items_ .empty ()) {
76
66
Items_.emplace_back (std::move (other.Items_ .front ()));
67
+ Size_ += Items_.back ().Buf .size ();
77
68
other.Items_ .pop_front ();
78
69
}
70
+ other.Size_ = 0 ;
79
71
return *this ;
80
72
}
81
73
82
74
TChunkedBuffer& TChunkedBuffer::Clear () {
83
75
Items_.clear ();
76
+ Size_ = 0 ;
84
77
return *this ;
85
78
}
86
79
@@ -90,6 +83,7 @@ TChunkedBuffer& TChunkedBuffer::Erase(size_t size) {
90
83
size_t toErase = std::min (buf.size (), size);
91
84
buf.Skip (toErase);
92
85
size -= toErase;
86
+ Size_ -= toErase;
93
87
if (buf.empty ()) {
94
88
Items_.pop_front ();
95
89
}
0 commit comments