Skip to content

Commit

Permalink
Remove double code execution
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
  • Loading branch information
phprus authored and vitaut committed Aug 5, 2022
1 parent 5a8b7cd commit 90c48b8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,13 @@ template <typename Char> struct formatter<std::tm, Char> {
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<Char>& 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'))
Expand All @@ -2040,12 +2047,6 @@ template <typename Char> struct formatter<std::tm, Char> {
return end;
}

public:
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
-> decltype(ctx.begin()) {
return this->do_parse(ctx.begin(), ctx.end());
}

template <typename FormatContext>
auto format(const std::tm& tm, FormatContext& ctx) const
-> decltype(ctx.out()) {
Expand Down

0 comments on commit 90c48b8

Please sign in to comment.