src: Remove unused Memchunk::shrink

This commit is contained in:
Tatsuhiro Tsujikawa 2015-08-15 00:57:58 +09:00
parent d1e49a196d
commit 8ce8b2af46
1 changed files with 1 additions and 27 deletions

View File

@ -43,18 +43,13 @@ namespace nghttp2 {
template <size_t N> struct Memchunk { template <size_t N> struct Memchunk {
Memchunk(std::unique_ptr<Memchunk> next_chunk) Memchunk(std::unique_ptr<Memchunk> next_chunk)
: pos(std::begin(buf)), last(pos), knext(std::move(next_chunk)), : pos(std::begin(buf)), last(pos), knext(std::move(next_chunk)),
kprev(nullptr), next(nullptr) { next(nullptr) {}
if (knext) {
knext->kprev = this;
}
}
size_t len() const { return last - pos; } size_t len() const { return last - pos; }
size_t left() const { return std::end(buf) - last; } size_t left() const { return std::end(buf) - last; }
void reset() { pos = last = std::begin(buf); } void reset() { pos = last = std::begin(buf); }
std::array<uint8_t, N> buf; std::array<uint8_t, N> buf;
uint8_t *pos, *last; uint8_t *pos, *last;
std::unique_ptr<Memchunk> knext; std::unique_ptr<Memchunk> knext;
Memchunk *kprev;
Memchunk *next; Memchunk *next;
static const size_t size = N; static const size_t size = N;
}; };
@ -82,27 +77,6 @@ template <typename T> struct Pool {
} }
freelist = m; freelist = m;
} }
void shrink(size_t max) {
auto m = freelist;
for (; m && poolsize > max;) {
auto next = m->next;
poolsize -= T::size;
auto p = m->kprev;
if (p) {
p->knext = std::move(m->knext);
if (p->knext) {
p->knext->kprev = p;
}
} else {
pool = std::move(m->knext);
if (pool) {
pool->kprev = nullptr;
}
}
m = next;
}
freelist = m;
}
void clear() { void clear() {
freelist = nullptr; freelist = nullptr;
pool = nullptr; pool = nullptr;