diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-12-23 19:04:50 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-12-23 19:05:28 -0800 |
commit | 6ad341ee4a0cca1a8b1744bc269282aafd765868 (patch) | |
tree | a255db204e29f00de2d2470c2074023fce7e98b7 /lib/xtime.h | |
parent | 2028f2854fd5b01fe71d3bac1909a031fd5a9d00 (diff) | |
download | gnulib-6ad341ee4a0cca1a8b1744bc269282aafd765868.tar.gz |
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.
Diffstat (limited to 'lib/xtime.h')
-rw-r--r-- | lib/xtime.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/xtime.h b/lib/xtime.h index 5dea467671..25185d01b0 100644 --- a/lib/xtime.h +++ b/lib/xtime.h @@ -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. */ |