-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -745,8 +745,10 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) { | |
const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_); | ||
size_t old_capacity = this->capacity(); | ||
size_t new_capacity = old_capacity + old_capacity / 2; | ||
if (size > new_capacity) new_capacity = size; | ||
else if (new_capacity > max_size) new_capacity = (std::max)(size, max_size); | ||
if (size > new_capacity) | ||
new_capacity = size; | ||
else if (new_capacity > max_size) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vitaut
Author
Contributor
|
||
new_capacity = (std::max)(size, max_size); | ||
T* old_data = this->data(); | ||
T* new_data = | ||
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity); | ||
|
@@ -979,13 +981,6 @@ template <> int count_digits<4>(detail::fallback_uintptr n); | |
# define FMT_ALWAYS_INLINE inline | ||
#endif | ||
|
||
// To suppress unnecessary security cookie checks | ||
#if FMT_MSC_VER && !FMT_CLANG_VERSION | ||
# define FMT_SAFEBUFFERS __declspec(safebuffers) | ||
#else | ||
# define FMT_SAFEBUFFERS | ||
#endif | ||
|
||
#ifdef FMT_BUILTIN_CLZ | ||
// Optional version of count_digits for better performance on 32-bit platforms. | ||
inline int count_digits(uint32_t n) { | ||
|
Shouldn't we remove this
else
? With it, asize > new_capacity
would skip the checknew_capacity > max_size
. So ifsize
were greater thanmax_size
, we'd allocate more than allowed.