Remove the nested read loops in FastCGIConn, hide complexity inside StreamBuffer

This commit is contained in:
Ian Gulliver
2019-04-28 17:50:44 +00:00
parent 323cfc15a5
commit 45e5570959
10 changed files with 73 additions and 51 deletions

View File

@@ -23,14 +23,6 @@ bool ConstBuffer::Discard(size_t len) {
return true;
}
void ConstBuffer::ResetRead() {
start_ = commit_;
}
void ConstBuffer::Commit() {
commit_ = start_;
}
Buffer::Buffer(char *buf, size_t size, size_t len)
: ConstBuffer(buf, size),
@@ -57,12 +49,11 @@ void Buffer::Wrote(size_t len) {
len_ += len;
}
void Buffer::Consume() {
if (commit_ == 0) {
void Buffer::Commit() {
if (start_ == 0) {
return;
}
memmove(buf_, &buf_[commit_], len_ - commit_);
len_ -= commit_;
start_ -= commit_;
commit_ = 0;
memmove(buf_, &buf_[start_], len_ - start_);
len_ -= start_;
start_ = 0;
}