From 90c48b852528b6f4de92e8d8b4332881f6df2474 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sat, 30 Jul 2022 12:06:59 +0500 Subject: [PATCH] Remove double code execution Signed-off-by: Vladislav Shchapov --- include/fmt/chrono.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 0e5382b3..b112f76e 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -2030,6 +2030,13 @@ template struct formatter { end = detail::parse_chrono_format(begin, end, detail::tm_format_checker()); // Replace default spec only if the new spec is not empty. if (end != begin) specs = {begin, detail::to_unsigned(end - begin)}; + return end; + } + + public: + FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) + -> decltype(ctx.begin()) { + auto end = this->do_parse(ctx.begin(), ctx.end()); // basic_string_view<>::compare isn't constexpr before C++17. if (specs.size() == 2 && specs[0] == Char('%')) { if (specs[1] == Char('F')) @@ -2040,12 +2047,6 @@ template struct formatter { return end; } - public: - FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) - -> decltype(ctx.begin()) { - return this->do_parse(ctx.begin(), ctx.end()); - } - template auto format(const std::tm& tm, FormatContext& ctx) const -> decltype(ctx.out()) {