[51/59] Refactor ‘if’ in __tzfile_compute

Message ID 20250105055750.1668721-52-eggert@cs.ucla.edu (mailing list archive)
State New
Headers
Series time: sync mktime from Gnulib |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Paul Eggert Jan. 5, 2025, 5:57 a.m. UTC
  * 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(-)
  

Patch

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
 	{