From 5a982c3e7b1e8931530e110bb5388047829fa4fe Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 11 Jul 2024 15:03:50 +0200 Subject: [PATCH 15/17] Decode current time directly to timespec * src/timefns.c (decode_time_components): If FASTER_TIMEFNS, when returning the current time and the desired form is struct timespec or time_t, return it directly rather than converting it to struct ticks_hz and then to struct timespec. This can avoid some mpz calculations and/or bignums. --- src/timefns.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/timefns.c b/src/timefns.c index 6949c83dbcb..ad39d1307cd 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -884,8 +884,14 @@ decode_time_components (enum timeform form, eassume (false); case TIMEFORM_NIL: - ticks = timespec_ticks (current_timespec ()); - hz = timespec_hz; + { + struct timespec now = current_timespec (); + if (FASTER_TIMEFNS + && (cform == CFORM_TIMESPEC || cform == CFORM_SECS_ONLY)) + return (struct err_time) { .time = { .ts = now } }; + ticks = timespec_ticks (now); + hz = timespec_hz; + } break; default: -- 2.34.1