From d26ea85663f5875c55209b34b867c7b6315744cc Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 29 Oct 2026 07:43:42 +0100 Subject: [PATCH] json_view: use while in check_utf8_bytewise Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/edit.hpp | 2 +- single_include/nlohmann/json_view.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/view/edit.hpp b/include/nlohmann/detail/view/edit.hpp index ab9503577..c542c1141 100644 --- a/include/nlohmann/detail/view/edit.hpp +++ b/include/nlohmann/detail/view/edit.hpp @@ -49,7 +49,7 @@ struct first_true : std::integral_constant < int, 1 + firs /// well-formed sequence can continue with (Unicode, Table 3-7). NLOHMANN_VIEW_ALWAYS_INLINE void check_utf8_bytewise(const unsigned char* p, std::size_t n, std::size_t i) { - for (; i < n;) + while (i < n) { const unsigned char c = p[i]; if (c < 0x80) diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 864b6e1e3..594708671 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -3835,7 +3835,7 @@ struct first_true : std::integral_constant < int, 1 + firs /// well-formed sequence can continue with (Unicode, Table 3-7). NLOHMANN_VIEW_ALWAYS_INLINE void check_utf8_bytewise(const unsigned char* p, std::size_t n, std::size_t i) { - for (; i < n;) + while (i < n) { const unsigned char c = p[i]; if (c < 0x80)