libstdc++: More efficient std::chrono::year::leap
authorCassio Neri <cassio.neri@gmail.com>
Wed, 23 Jun 2021 14:32:16 +0000 (15:32 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 23 Jun 2021 17:28:08 +0000 (18:28 +0100)
commitb92d12d3fe3f1aa56d190d960e40c62869a6cfbb
treee27d94f4883acb7bcf3346f6a2e7b8b8a316d921
parent53330b7d6848209d658c02be76c36aa5475a88c9
libstdc++: More efficient std::chrono::year::leap

Simple change to std::chrono::year::is_leap. If a year is multiple of 100,
then it's divisible by 400 if and only if it's divisible by 16. The latter
allows for better code generation.

The expression is then either y%16 or y%4 which are both powers of two
and so it can be rearranged to use simple bitmask operations.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Ulrich Drepper <drepper@redhat.com>
libstdc++-v3/ChangeLog:

* include/std/chrono (chrono::year::is_leap()): Optimize.
libstdc++-v3/include/std/chrono