From f2a7e6935f2067da4ca27e8ec36caaddb50ad256 Mon Sep 17 00:00:00 2001 From: Roberto Rossini <71787608+robomics@users.noreply.github.com> Date: Fri, 2 Jun 2023 22:58:44 +0200 Subject: [PATCH] Update starts_with to use a single return statement --- include/fmt/core.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 83adfe2a..73974a74 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -681,12 +681,14 @@ template class basic_format_parse_context { constexpr bool starts_with(iterator prefix) const noexcept { auto first = begin(); auto last = end(); + bool mismatch_found = false; while (first != last && *prefix != '\0') { if (*prefix++ != *first++) { - return false; + mismatch_found = true; + break; } } - return *prefix == '\0'; + return !mismatch_found && *prefix == '\0'; } /** Advances the begin iterator to ``it``. */