From 38a76bafce303d211043fd118119c9431cdbe932 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 16 Oct 2020 17:37:09 +0300 Subject: add a separate Buffer class --- src/handle.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/handle.cpp b/src/handle.cpp index a6ab3a5..1147cf6 100644 --- a/src/handle.cpp +++ b/src/handle.cpp @@ -3,6 +3,7 @@ // For details, see https://github.com/egor-tensin/winapi-common. // Distributed under the MIT License. +#include #include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include namespace winapi { namespace { @@ -100,15 +102,13 @@ bool Handle::read_chunk(Buffer& buffer) const { } } -Handle::Buffer Handle::read() const { +Buffer Handle::read() const { Buffer buffer; - Buffer chunk; while (true) { + Buffer chunk; const auto next = read_chunk(chunk); - - buffer.reserve(buffer.size() + chunk.size()); - buffer.insert(buffer.cend(), chunk.cbegin(), chunk.cend()); + buffer.add(chunk); if (!next) { break; -- cgit v1.2.3