+22
-19
lines changedFilter options
+22
-19
lines changed Original file line number Diff line number Diff line change
@@ -78,6 +78,11 @@
78
78
#else
79
79
# define FMT_HAS_INCLUDE(x) 0
80
80
#endif
81
+
#ifdef __has_builtin
82
+
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
83
+
#else
84
+
# define FMT_HAS_BUILTIN(x) 0
85
+
#endif
81
86
#ifdef __has_cpp_attribute
82
87
# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
83
88
#else
@@ -455,19 +460,16 @@ constexpr auto is_utf8_enabled() -> bool { return "\u00A7"[1] == '\xA7'; }
455
460
// It is a macro for better debug codegen without if constexpr.
456
461
#define FMT_USE_UTF8 (!FMT_MSC_VERSION || fmt::detail::is_utf8_enabled())
457
462
463
+
template <typename T> constexpr const char* narrow(const T*) { return nullptr; }
464
+
constexpr FMT_ALWAYS_INLINE const char* narrow(const char* s) { return s; }
465
+
458
466
#ifndef FMT_UNICODE
459
467
# define FMT_UNICODE 1
460
468
#endif
461
469
462
470
static_assert(!FMT_UNICODE || FMT_USE_UTF8,
463
471
"Unicode support requires compiling with /utf-8");
464
472
465
-
template <typename Char> FMT_CONSTEXPR auto length(const Char* s) -> size_t {
466
-
size_t len = 0;
467
-
while (*s++) ++len;
468
-
return len;
469
-
}
470
-
471
473
template <typename Char>
472
474
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
473
475
-> int {
@@ -536,13 +538,20 @@ template <typename Char> class basic_string_view {
536
538
constexpr basic_string_view(std::nullptr_t) = delete;
537
539
538
540
/// Constructs a string reference object from a C string.
539
-
FMT_CONSTEXPR20
540
-
basic_string_view(const Char* s)
541
-
: data_(s),
542
-
size_(detail::const_check(std::is_same<Char, char>::value &&
543
-
!detail::is_constant_evaluated(false))
544
-
? strlen(reinterpret_cast<const char*>(s))
545
-
: detail::length(s)) {}
541
+
#if FMT_GCC_VERSION
542
+
FMT_ALWAYS_INLINE
543
+
#endif
544
+
FMT_CONSTEXPR20 basic_string_view(const Char* s) : data_(s) {
545
+
#if FMT_HAS_BUILTIN(__buitin_strlen) || FMT_GCC_VERSION || FMT_CLANG_VERSION
546
+
if (std::is_same<Char, char>::value) {
547
+
size_ = __builtin_strlen(detail::narrow(s));
548
+
return;
549
+
}
550
+
#endif
551
+
size_t len = 0;
552
+
while (*s++) ++len;
553
+
size_ = len;
554
+
}
546
555
547
556
/// Constructs a string reference from a `std::basic_string` or a
548
557
/// `std::basic_string_view` object.
Original file line number Diff line number Diff line change
@@ -81,12 +81,6 @@
81
81
# define FMT_SO_VISIBILITY(value)
82
82
#endif
83
83
84
-
#ifdef __has_builtin
85
-
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
86
-
#else
87
-
# define FMT_HAS_BUILTIN(x) 0
88
-
#endif
89
-
90
84
#if FMT_GCC_VERSION || FMT_CLANG_VERSION
91
85
# define FMT_NOINLINE __attribute__((noinline))
92
86
#else
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4