From 58d792b6d3351c5261ec4cc525265ba8b1b9fd30 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 14 Jul 2024 07:05:18 -0700 Subject: [PATCH] Apply minor optimizations --- include/fmt/base.h | 1 + test/scan.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 18fe100384ae..4d6a33bc51db 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -467,6 +467,7 @@ template FMT_CONSTEXPR auto length(const Char* s) -> size_t { template FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n) -> int { + if (!is_constant_evaluated() && sizeof(Char) == 1) return memcmp(s1, s2, n); for (; n != 0; ++s1, ++s2, --n) { if (*s1 < *s2) return -1; if (*s1 > *s2) return 1; diff --git a/test/scan.h b/test/scan.h index baa932bcf313..1bcdc5489cec 100644 --- a/test/scan.h +++ b/test/scan.h @@ -553,7 +553,7 @@ struct scan_handler { return begin; } - void on_error(const char* message) { report_error(message); } + FMT_NORETURN void on_error(const char* message) { report_error(message); } }; void vscan(detail::scan_buffer& buf, string_view fmt, scan_args args) {