Commit 6ad341ee authored by Paul Eggert's avatar Paul Eggert
Browse files

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.
parent 2028f285
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.
......@@ -61,7 +61,7 @@ xtime_nonnegative_sec (xtime_t t)
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. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment