Remove FMT_SAFEBUFFERS (#1966)

This commit is contained in:
Victor Zverovich 2020-10-29 17:42:45 -07:00
parent 4081b2fe94
commit 112755cf91
2 changed files with 11 additions and 21 deletions

View File

@ -1646,8 +1646,7 @@ struct fixed_handler {
// Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox.
namespace dragonbox {
// Computes 128-bit result of multiplication of two 64-bit unsigned integers.
FMT_SAFEBUFFERS inline uint128_wrapper umul128(uint64_t x,
uint64_t y) FMT_NOEXCEPT {
inline uint128_wrapper umul128(uint64_t x, uint64_t y) FMT_NOEXCEPT {
#if FMT_USE_INT128
return static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
#elif defined(_MSC_VER) && defined(_M_X64)
@ -1675,8 +1674,7 @@ FMT_SAFEBUFFERS inline uint128_wrapper umul128(uint64_t x,
}
// Computes upper 64 bits of multiplication of two 64-bit unsigned integers.
FMT_SAFEBUFFERS inline uint64_t umul128_upper64(uint64_t x,
uint64_t y) FMT_NOEXCEPT {
inline uint64_t umul128_upper64(uint64_t x, uint64_t y) FMT_NOEXCEPT {
#if FMT_USE_INT128
auto p = static_cast<uint128_t>(x) * static_cast<uint128_t>(y);
return static_cast<uint64_t>(p >> 64);
@ -1689,8 +1687,7 @@ FMT_SAFEBUFFERS inline uint64_t umul128_upper64(uint64_t x,
// Computes upper 64 bits of multiplication of a 64-bit unsigned integer and a
// 128-bit unsigned integer.
FMT_SAFEBUFFERS inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y)
FMT_NOEXCEPT {
inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT {
uint128_wrapper g0 = umul128(x, y.high());
g0 += umul128_upper64(x, y.low());
return g0.high();
@ -1704,8 +1701,7 @@ inline uint32_t umul96_upper32(uint32_t x, uint64_t y) FMT_NOEXCEPT {
// Computes middle 64 bits of multiplication of a 64-bit unsigned integer and a
// 128-bit unsigned integer.
FMT_SAFEBUFFERS inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y)
FMT_NOEXCEPT {
inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT {
uint64_t g01 = x * y.high();
uint64_t g10 = umul128_upper64(x, y.low());
return g01 + g10;
@ -2124,8 +2120,8 @@ FMT_ALWAYS_INLINE int remove_trailing_zeros(uint64_t& n) FMT_NOEXCEPT {
// The main algorithm for shorter interval case
template <class T>
FMT_ALWAYS_INLINE FMT_SAFEBUFFERS decimal_fp<T> shorter_interval_case(
int exponent) FMT_NOEXCEPT {
FMT_ALWAYS_INLINE decimal_fp<T> shorter_interval_case(int exponent)
FMT_NOEXCEPT {
decimal_fp<T> ret_value;
// Compute k and beta
const int minus_k = floor_log10_pow2_minus_log10_4_over_3(exponent);
@ -2171,8 +2167,7 @@ FMT_ALWAYS_INLINE FMT_SAFEBUFFERS decimal_fp<T> shorter_interval_case(
return ret_value;
}
template <typename T>
FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
template <typename T> decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
// Step 1: integer promotion & Schubfach multiplier calculation.
using carrier_uint = typename float_info<T>::carrier_uint;

View File

@ -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)
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) {