diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-12-10 17:33:50 -0800 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-12-10 17:33:50 -0800 |
commit | 6bddd54f9d1195c4dcef04e096474c2ff7066f1d (patch) | |
tree | 6b775ea0a35f36ad17a7d0945eedc8ba7d0f4e1f /contrib/epee/src | |
parent | Merge pull request #6977 (diff) | |
parent | Change to more efficient allocation strategy in byte_stream (diff) | |
download | monero-6bddd54f9d1195c4dcef04e096474c2ff7066f1d.tar.xz |
Merge pull request #7003
08eb0949f Change to more efficient allocation strategy in byte_stream (Lee Clagett)
Diffstat (limited to 'contrib/epee/src')
-rw-r--r-- | contrib/epee/src/byte_stream.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/epee/src/byte_stream.cpp b/contrib/epee/src/byte_stream.cpp index e87d9f0bc..73bba92f2 100644 --- a/contrib/epee/src/byte_stream.cpp +++ b/contrib/epee/src/byte_stream.cpp @@ -34,6 +34,11 @@ #include <iostream> +namespace +{ + constexpr const std::size_t minimum_increase = 4096; +} + namespace epee { void byte_stream::overflow(const std::size_t requested) @@ -46,7 +51,7 @@ namespace epee const std::size_t len = size(); const std::size_t cap = capacity(); - const std::size_t increase = std::max(need, increase_size()); + const std::size_t increase = std::max(std::max(need, cap), minimum_increase); next_write_ = nullptr; end_ = nullptr; @@ -62,8 +67,7 @@ namespace epee byte_stream::byte_stream(byte_stream&& rhs) noexcept : buffer_(std::move(rhs.buffer_)), next_write_(rhs.next_write_), - end_(rhs.end_), - increase_size_(rhs.increase_size_) + end_(rhs.end_) { rhs.next_write_ = nullptr; rhs.end_ = nullptr; @@ -76,7 +80,6 @@ namespace epee buffer_ = std::move(rhs.buffer_); next_write_ = rhs.next_write_; end_ = rhs.end_; - increase_size_ = rhs.increase_size_; rhs.next_write_ = nullptr; rhs.end_ = nullptr; } |