Add ChainBufferReader::advance debug.
This commit is contained in:
parent
5b6301c40c
commit
40740597f7
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#include "td/utils/buffer.h"
|
#include "td/utils/buffer.h"
|
||||||
|
|
||||||
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/port/thread_local.h"
|
#include "td/utils/port/thread_local.h"
|
||||||
#include "td/utils/ThreadSafeCounter.h"
|
#include "td/utils/ThreadSafeCounter.h"
|
||||||
|
|
||||||
@ -106,6 +107,12 @@ void BufferAllocator::dec_ref_cnt(BufferRaw *ptr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ChainBufferReader::advance(size_t offset, MutableSlice dest) {
|
||||||
|
LOG_CHECK(offset <= size()) << offset << " " << size() << " " << end_.offset() << " " << begin_.offset() << " "
|
||||||
|
<< sync_flag_ << " " << dest.size();
|
||||||
|
return begin_.advance(offset, dest);
|
||||||
|
}
|
||||||
|
|
||||||
BufferRaw *BufferAllocator::create_buffer_raw(size_t size) {
|
BufferRaw *BufferAllocator::create_buffer_raw(size_t size) {
|
||||||
size = (size + 7) & -8;
|
size = (size + 7) & -8;
|
||||||
|
|
||||||
@ -124,6 +131,7 @@ void BufferBuilder::append(BufferSlice slice) {
|
|||||||
}
|
}
|
||||||
append_slow(std::move(slice));
|
append_slow(std::move(slice));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBuilder::append(Slice slice) {
|
void BufferBuilder::append(Slice slice) {
|
||||||
if (append_inplace(slice)) {
|
if (append_inplace(slice)) {
|
||||||
return;
|
return;
|
||||||
@ -137,6 +145,7 @@ void BufferBuilder::prepend(BufferSlice slice) {
|
|||||||
}
|
}
|
||||||
prepend_slow(std::move(slice));
|
prepend_slow(std::move(slice));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBuilder::prepend(Slice slice) {
|
void BufferBuilder::prepend(Slice slice) {
|
||||||
if (prepend_inplace(slice)) {
|
if (prepend_inplace(slice)) {
|
||||||
return;
|
return;
|
||||||
@ -177,9 +186,11 @@ bool BufferBuilder::append_inplace(Slice slice) {
|
|||||||
buffer_writer_.confirm_append(slice.size());
|
buffer_writer_.confirm_append(slice.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBuilder::append_slow(BufferSlice slice) {
|
void BufferBuilder::append_slow(BufferSlice slice) {
|
||||||
to_append_.push_back(std::move(slice));
|
to_append_.push_back(std::move(slice));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferBuilder::prepend_inplace(Slice slice) {
|
bool BufferBuilder::prepend_inplace(Slice slice) {
|
||||||
if (!to_prepend_.empty()) {
|
if (!to_prepend_.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -193,7 +204,9 @@ bool BufferBuilder::prepend_inplace(Slice slice) {
|
|||||||
buffer_writer_.confirm_prepend(slice.size());
|
buffer_writer_.confirm_prepend(slice.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBuilder::prepend_slow(BufferSlice slice) {
|
void BufferBuilder::prepend_slow(BufferSlice slice) {
|
||||||
to_prepend_.push_back(std::move(slice));
|
to_prepend_.push_back(std::move(slice));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -610,10 +610,7 @@ class ChainBufferReader {
|
|||||||
begin_.confirm_read(size);
|
begin_.confirm_read(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t advance(size_t offset, MutableSlice dest = MutableSlice()) {
|
size_t advance(size_t offset, MutableSlice dest = MutableSlice());
|
||||||
CHECK(offset <= size());
|
|
||||||
return begin_.advance(offset, dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const {
|
size_t size() const {
|
||||||
return end_.offset() - begin_.offset();
|
return end_.offset() - begin_.offset();
|
||||||
|
Loading…
Reference in New Issue
Block a user