Remove a redundant branch

This commit is contained in:
Victor Zverovich 2020-05-22 14:14:57 -07:00
parent 8cadb96506
commit a7fb321ac6
2 changed files with 12 additions and 3 deletions

View File

@ -173,7 +173,7 @@
# if FMT_GCC_VERSION && FMT_USE_CONSTEXPR # if FMT_GCC_VERSION && FMT_USE_CONSTEXPR
# define FMT_INLINE inline __attribute__((always_inline)) # define FMT_INLINE inline __attribute__((always_inline))
# else # else
# define FMT_INLINE # define FMT_INLINE inline
# endif # endif
#endif #endif

View File

@ -288,6 +288,13 @@ template <> constexpr int num_bits<fallback_uintptr>() {
std::numeric_limits<unsigned char>::digits); std::numeric_limits<unsigned char>::digits);
} }
FMT_INLINE void assume(bool condition) {
(void)condition;
#if FMT_HAS_BUILTIN(__builtin_assume)
__builtin_assume(condition);
#endif
}
// A workaround for gcc 4.8 to make void_t work in a SFINAE context. // A workaround for gcc 4.8 to make void_t work in a SFINAE context.
template <typename... Ts> struct void_t_impl { using type = void; }; template <typename... Ts> struct void_t_impl { using type = void; };
@ -2508,7 +2515,7 @@ template <typename Handler, typename Char> struct id_adapter {
}; };
template <typename Char, typename Handler> template <typename Char, typename Handler>
FMT_CONSTEXPR FMT_INLINE const Char* parse_replacement_field( FMT_CONSTEXPR_DECL FMT_INLINE const Char* parse_replacement_field(
const Char* begin, const Char* end, Handler&& handler) { const Char* begin, const Char* end, Handler&& handler) {
++begin; ++begin;
if (begin == end) return handler.on_error("invalid format string"), end; if (begin == end) return handler.on_error("invalid format string"), end;
@ -3349,7 +3356,9 @@ template <typename T> inline std::wstring to_wstring(const T& value) {
template <typename Char, size_t SIZE> template <typename Char, size_t SIZE>
std::basic_string<Char> to_string(const basic_memory_buffer<Char, SIZE>& buf) { std::basic_string<Char> to_string(const basic_memory_buffer<Char, SIZE>& buf) {
return std::basic_string<Char>(buf.data(), buf.size()); auto size = buf.size();
detail::assume(size < std::basic_string<Char>().max_size());
return std::basic_string<Char>(buf.data(), size);
} }
template <typename Char> template <typename Char>