mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 04:47:29 +02:00
Refactor read_size_helper
This commit is contained in:
committed by
Vinnie Falco
parent
753281959e
commit
0a1c24eb9f
@ -14,6 +14,7 @@
|
||||
* Add headers_parser
|
||||
* Engaged invokable is destructible
|
||||
* Improve websocket example in README.md
|
||||
* Refactor read_size_helper
|
||||
|
||||
API Changes:
|
||||
|
||||
|
@ -856,10 +856,12 @@ read_size_helper(basic_streambuf<
|
||||
Allocator> const& streambuf, std::size_t max_size)
|
||||
{
|
||||
auto const avail = streambuf.capacity() - streambuf.size();
|
||||
if(avail == 0)
|
||||
return std::min(max_size,
|
||||
std::max<std::size_t>(512, streambuf.alloc_size_));
|
||||
return std::min(max_size, avail);
|
||||
if (avail > 0)
|
||||
return std::min(avail, max_size);
|
||||
constexpr std::size_t low = 512;
|
||||
if (streambuf.alloc_size_ > low)
|
||||
return std::min(max_size, streambuf.alloc_size_);
|
||||
return std::min(max_size, low);
|
||||
}
|
||||
|
||||
template<class Alloc, class T>
|
||||
|
Reference in New Issue
Block a user