-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize %T in tm formatting #2500
Conversation
6c6239d
to
a9113e5
Compare
@@ -563,7 +564,13 @@ template <typename Char> struct formatter<std::tm, Char> { | |||
while (end != ctx.end() && *end != '}') ++end; | |||
auto size = detail::to_unsigned(end - it); | |||
specs = {it, size}; | |||
if (specs == string_view("%F", 2)) spec_ = spec::year_month_day; | |||
// basic_string_view<>::compare isn't constexpr before C++17 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no basic_string_view<>
before C++17.
Could it be that the internal replacement should be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem in std::char_traits<>::compare
:
Lines 472 to 478 in 3d0c7ae
FMT_CONSTEXPR_CHAR_TRAITS auto compare(basic_string_view other) const -> int { | |
size_t str_size = size_ < other.size_ ? size_ : other.size_; | |
int result = std::char_traits<Char>::compare(data_, other.data_, str_size); | |
if (result == 0) | |
result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1); | |
return result; | |
} |
constexpr std::char_traits<>::compare
starts from C++17 only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
include/fmt/chrono.h
Outdated
@@ -1217,6 +1230,7 @@ class weekday { | |||
}; | |||
|
|||
class year_month_day {}; | |||
class hh_mm_ss {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Removed.
a9113e5
to
7407f76
Compare
I'm not sure if we should add more special cases but it would be nice to get rid of |
… шаблон литерального оператора должен иметь список параметров шаблона, эквивалентный "<char ...>" template <detail_exported::fixed_string Str> constexpr auto operator""_a() { ^ Signed-off-by: Vladislav Shchapov <[email protected]>
Optimization
%T
in tm formatting like this: 67cb2daAnd fix wchar_t tm formatting error:
Maybe I should add the use of
write_digit2_separated
for formats:%Y-%m-%d
%H:%M:%S
%Y-%m-%d %H:%M:%S
%Y-%m-%dT%H:%M:%S
?