Re: [PATCH 4/4] libstdc++: More efficient last day of month.

2021-02-24 Thread Jonathan Wakely via Gcc-patches
On 23/02/21 23:13 +0100, Matthias Kretz wrote: I like the idea. On Dienstag, 23. Februar 2021 14:25:10 CET Cassio Neri via Libstdc++ wrote: ((__m ^ (__m >> 3)) & 1) | 30 Note that you can drop the `& 1` part. 30 in binary is 0b0. ORing with a value in [0, 0b01101] will only toggle the

Re: [PATCH 4/4] libstdc++: More efficient last day of month.

2021-02-23 Thread Matthias Kretz
I like the idea. On Dienstag, 23. Februar 2021 14:25:10 CET Cassio Neri via Libstdc++ wrote: > ((__m ^ (__m >> 3)) & 1) | 30 Note that you can drop the `& 1` part. 30 in binary is 0b0. ORing with a value in [0, 0b01101] will only toggle the last bit. --

[PATCH 4/4] libstdc++: More efficient last day of month.

2021-02-23 Thread Cassio Neri via Gcc-patches
This patch reimplements std::chrono::year_month_day_last:day() which yields the last day of a particular month. The current implementation uses a look-up table implemented as an unsigned[12] array. The new implementation instead is based on the fact that a month m in [1, 12], except for m == 2