Thanks for the further performance improvement to zic. I installed that, followed by the attached minor fixups.
From f902d1b45b8e2a86146df036d05c667671515c8a Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Fri, 7 Aug 2026 17:10:52 -0500
Subject: [PROPOSED] Simplify recent year-skipping change in zic.c
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* NEWS: Mention today’s year-skipping change.
* zic.c (outzone): Clarify the loop control a bit,
and avoid an unnecessary test instruction by initializing
next_year to max_year, not to 0.  Reindent recently-added
code to more indentation-friendly indent levels.
---
 NEWS  |  4 ++--
 zic.c | 28 ++++++++++++++--------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/NEWS b/NEWS
index a446c6eb..ebb5458e 100644
--- a/NEWS
+++ b/NEWS
@@ -46,8 +46,8 @@ Unreleased, experimental changes
 
   Changes to code
 
-    zic now rejects Link targets that would have invalid names,
-    and efficiently processes Leap and Expires lines containing years
+    zic now rejects Link targets that would have invalid names, and
+    more efficiently processes Expires, Leap and Rule lines with years
     far in the past or future.  (Thanks to Darren Carreras.)
 
     zic now ports to systems that report lack of link support via
diff --git a/zic.c b/zic.c
index 1d9c0b2a..761f9e0d 100644
--- a/zic.c
+++ b/zic.c
@@ -3544,12 +3544,13 @@ outzone(const struct zone *zpfirst, ptrdiff_t zonecount)
 			} else
 				defaulttype = type;
 		} else {
-		  zic_t year;
-		  for (year = min_year; ; ) {
-			bool next_year_found = false;
-			zic_t next_year = 0;
+		  zic_t year, next_year;
+		  bool try_next_year = true;
+		  for (year = min_year; try_next_year; year = next_year) {
 			if (useuntil && year > zp->z_untilrule.r_hiyear)
 				break;
+			try_next_year = false;
+			next_year = max_year;
 			/*
 			** Mark which rules to do in the current year.
 			** For those to do, calculate rpytime(rp, year);
@@ -3561,15 +3562,17 @@ outzone(const struct zone *zpfirst, ptrdiff_t zonecount)
 				struct rule *rp = &zp->z_rules[j];
 				eats(zp->z_filenum, zp->z_linenum,
 				     rp->r_filenum, rp->r_linenum);
-				/* Find the next year in which any rule can apply.  */
+
+				/* Keep track of the earliest year after YEAR
+				   in which some rule <= J applies.  */
 				if (year < rp->r_hiyear) {
-					zic_t next = max(year + 1, rp->r_loyear);
-					if (next <= max_year
-					    && (!next_year_found || next < next_year)) {
-						next_year_found = true;
-						next_year = next;
-					}
+				  zic_t next = max(year + 1, rp->r_loyear);
+				  if (next <= next_year) {
+				    next_year = next;
+				    try_next_year = true;
+				  }
 				}
+
 				rp->r_todo = year >= rp->r_loyear &&
 						year <= rp->r_hiyear;
 				if (rp->r_todo) {
@@ -3685,9 +3688,6 @@ outzone(const struct zone *zpfirst, ptrdiff_t zonecount)
 				  nonTZlimtype = type;
 				}
 			}
-			if (!next_year_found)
-				break;
-			year = next_year;
 		  }
 		}
 		if (usestart) {
-- 
2.55.0

Reply via email to