Re: [PATCH] libstdc++: Improve operator-(weekday x, weekday y).

2023-11-14 Thread Jonathan Wakely
On Tue, 14 Nov 2023 at 00:27, Cassio Neri wrote: > > 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

[PATCH] libstdc++: Improve operator-(weekday x, weekday y).

2023-11-13 Thread Cassio Neri
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 allowe