[PATCH 51/59] Refactor ‘if’ in __tzfile_compute
Paul Eggert
eggert@cs.ucla.edu
Sun Jan 5 05:57:26 GMT 2025
* time/tzfile.c (__tzfile_compute): Negate the sense of an ‘if’ to
simplify future changes.
---
time/tzfile.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/time/tzfile.c b/time/tzfile.c
index 8b5faad424..37b194df16 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -614,20 +614,18 @@ __tzfile_compute (__time64_t timer, int use_localtime,
}
else if (timecnt == 0 || timer >= transitions[timecnt - 1])
{
- /* TIMER is after the last transition. Do not use the TZ
- string if it is absent or if we cannot convert to the
- broken down structure. */
- if (__glibc_unlikely (tzspec == NULL)
- || __glibc_unlikely (__offtime (timer, 0, 0, tp) == NULL))
+ /* TIMER is after the last transition. Use the TZ string if
+ it is present and we can convert to the broken down structure. */
+ if (__glibc_likely (tzspec != NULL)
+ && __glibc_likely (__offtime (timer, 0, 0, tp) != NULL))
{
- i = timecnt;
- goto found;
+ /* Use the rules from the TZ string to compute the change. */
+ __tz_compute (timer, tp);
+ return;
}
- /* Use the rules from the TZ string to compute the change. */
- __tz_compute (timer, tp);
-
- return;
+ i = timecnt;
+ goto found;
}
else
{
--
2.45.2
More information about the Libc-alpha
mailing list