aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorCassio Neri <cassio.neri@gmail.com>2023-11-14 00:27:39 +0000
committerJonathan Wakely <jwakely@redhat.com>2023-11-14 22:32:09 +0000
commitf71352c71d78ac977ea0e71a6900699a8cf09219 (patch)
tree717f7ee03699fb6ad845634e4503edbf1f358cc0 /libcpp
parentf6ce081d0ffb5f25d71eb2f30fcfdff7f20dba22 (diff)
downloadgcc-f71352c71d78ac977ea0e71a6900699a8cf09219.zip
gcc-f71352c71d78ac977ea0e71a6900699a8cf09219.tar.gz
gcc-f71352c71d78ac977ea0e71a6900699a8cf09219.tar.bz2
libstdc++: Improve operator-(weekday x, weekday y)
The current implementation calls __detail::__modulo which is relatively expensive. A better implementation is possible if we assume that x.ok() && y.ok() == true, so that n = x.c_encoding() - y.c_encoding() is in [-6, 6]. In this case, it suffices to return n >= 0 ? n : n + 7. The above is allowed by [time.cal.wd.nonmembers]/5: the returned value is unspecified when x.ok() || y.ok() == false. The assembly emitted for x86-64 and ARM can be seen in: https://godbolt.org/z/nMdc5vv9n. libstdc++-v3/ChangeLog: * include/std/chrono (operator-(const weekday&, const weekday&)): Optimize.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions