2019-12-23 Paul Eggert <eggert@cs.ucla.edu>
+ mktime: tweak division performance
+ * config/srclist.txt: Do not sync mktime.c for now.
+ * lib/mktime.c (shr, ydhms_diff):
+ Redo with neither ‘%’ nor conditional branches.
+
gethrxtime: improve xtime_sec performance
Performanced analyzed by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2019-12/msg00200.html
$LIBCSRC posix/regex_internal.h lib
$LIBCSRC posix/regexec.c lib
$LIBCSRC time/timegm.c lib
-$LIBCSRC time/mktime.c lib
+#$LIBCSRC time/mktime.c lib
$LIBCSRC time/mktime-internal.h lib
# \f
long_int one = 1;
return (-one >> 1 == -1
? a >> b
- : a / (one << b) - (a % (one << b) < 0));
+ : (a + (a < 0)) / (one << b) - (a < 0));
}
/* Bounds for the intersection of __time64_t and long_int. */
Take care to avoid integer overflow here. */
int a4 = shr (year1, 2) + shr (TM_YEAR_BASE, 2) - ! (year1 & 3);
int b4 = shr (year0, 2) + shr (TM_YEAR_BASE, 2) - ! (year0 & 3);
- int a100 = a4 / 25 - (a4 % 25 < 0);
- int b100 = b4 / 25 - (b4 % 25 < 0);
+ int a100 = (a4 + (a4 < 0)) / 25 - (a4 < 0);
+ int b100 = (b4 + (b4 < 0)) / 25 - (b4 < 0);
int a400 = shr (a100, 2);
int b400 = shr (b100, 2);
int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);