Performanced analyzed by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00200.html
* lib/xtime.h (xtime_sec): Redo with neither ‘%’ nor conditional
branches.
+2019-12-23 Paul Eggert <eggert@cs.ucla.edu>
+
+ gethrxtime: improve xtime_sec performance
+ Performanced analyzed by Bruno Haible in:
+ https://lists.gnu.org/r/bug-gnulib/2019-12/msg00200.html
+ * lib/xtime.h (xtime_sec): Redo with neither ‘%’ nor conditional
+ branches.
+
2019-12-23 Bruno Haible <bruno@clisp.org>
setlocale-null: Export the lock function also on non-Windows platforms.
XTIME_INLINE xtime_t
xtime_sec (xtime_t t)
{
- return t / XTIME_PRECISION - (t % XTIME_PRECISION < 0);
+ return (t + (t < 0)) / XTIME_PRECISION - (t < 0);
}
/* Return the number of nanoseconds in T, which must be nonnegative. */