From: Paul Eggert <eggert@cs.ucla.edu>
To: libc-alpha@sourceware.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 23/59] Minor tzfile.c clarity improvements
Date: Sat, 4 Jan 2025 21:56:58 -0800 [thread overview]
Message-ID: <20250105055750.1668721-24-eggert@cs.ucla.edu> (raw)
In-Reply-To: <01207110-bd60-46ae-9c08-fb39c2011067@cs.ucla.edu>
* time/tzfile.c (__tzfile_read, __tzfile_compute):
Avoid some unnecesary unsigned char -> int conversions.
Improve clarity of loop controlling.
---
time/tzfile.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/time/tzfile.c b/time/tzfile.c
index 8d8391acfe..291b3aa0dd 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -508,16 +508,14 @@ __tzfile_read (const char *file)
transitioned to earliest in time. */
__tzname[0] = NULL;
__tzname[1] = NULL;
- for (i = timecnt; i > 0; )
+ for (i = timecnt; i > 0; i--)
{
- int type = type_idxs[--i];
- int dst = types[type].dst;
+ struct ttinfo *ttype = &types[type_idxs[i - 1]];
+ unsigned char dst = ttype->dst;
if (__tzname[dst] == NULL)
{
- int idx = types[type].idx;
-
- __tzname[dst] = __tzstring (&zone_names[idx]);
+ __tzname[dst] = __tzstring (&zone_names[ttype->idx]);
if (__tzname[1 - dst] != NULL)
break;
@@ -699,22 +697,19 @@ __tzfile_compute (__time64_t timer, int use_localtime,
&& (i == timecnt || timer < transitions[i])); */
__tzname[types[type_idxs[i - 1]].dst]
= __tzstring (&zone_names[types[type_idxs[i - 1]].idx]);
- tzidx j = i;
- while (j < timecnt)
+
+ for (tzidx j = i; j < timecnt; j++)
{
- int type = type_idxs[j];
- int dst = types[type].dst;
- int idx = types[type].idx;
+ struct ttinfo *ttype = &types[type_idxs[j]];
+ unsigned char dst = ttype->dst;
if (__tzname[dst] == NULL)
{
- __tzname[dst] = __tzstring (&zone_names[idx]);
+ __tzname[dst] = __tzstring (&zone_names[ttype->idx]);
if (__tzname[1 - dst] != NULL)
break;
}
-
- ++j;
}
if (__glibc_unlikely (__tzname[0] == NULL))
--
2.45.2
next prev parent reply other threads:[~2025-01-05 5:59 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-02 17:42 [PATCH v2 0/4] mktime tm_isdst compatibility improvements Florian Weimer
2025-01-02 17:42 ` [PATCH v2 1/4] time: Use __tz_convert in mktime implementation Florian Weimer
2025-01-02 17:42 ` [PATCH v2 2/4] time: Push tzset lock into callers of time functions Florian Weimer
2025-01-02 17:42 ` [PATCH v2 3/4] time: Do not perform forced DST adjustment for DST-less zones Florian Weimer
2025-01-02 17:42 ` [PATCH v2 4/4] time: Implement the glibc.time.mktime_dst_adjustment tunable Florian Weimer
2025-01-05 2:58 ` [PATCH v2 0/4] mktime tm_isdst compatibility improvements Paul Eggert
2025-01-05 5:56 ` [PATCH 00/59] time: sync mktime from Gnulib Paul Eggert
2025-01-06 14:30 ` Carlos O'Donell
2025-01-06 21:34 ` Joseph Myers
2025-01-06 21:43 ` Paul Eggert
2025-01-05 5:56 ` [PATCH 01/59] Split intprops.h into two Paul Eggert
2025-01-05 5:56 ` [PATCH 02/59] Support stdckdint.h internally if older GCC Paul Eggert
2025-01-05 5:56 ` [PATCH 03/59] Fix mishandling of default DST rule Paul Eggert
2025-01-05 5:56 ` [PATCH 04/59] Don't worry about !TZDEFAULT Paul Eggert
2025-01-05 5:56 ` [PATCH 05/59] Support static_assert in pre-C23 C Paul Eggert
2025-01-05 5:56 ` [PATCH 06/59] Sync mktime.c from Gnulib 2024-10-04 Paul Eggert
2025-01-05 5:56 ` [PATCH 07/59] Document mktime out-of-range + tm_isdst Paul Eggert
2025-01-05 8:03 ` Florian Weimer
2025-01-05 14:03 ` Paul Eggert
2025-01-05 5:56 ` [PATCH 08/59] Push tzset lock into callers of time functions Paul Eggert
2025-01-05 5:56 ` [PATCH 09/59] Omit parse_offset unnecessary *tz == '\0' Paul Eggert
2025-01-05 5:56 ` [PATCH 10/59] Don’t assume TZif bloat is likely Paul Eggert
2025-01-05 5:56 ` [PATCH 11/59] tzset no longer calls ftello Paul Eggert
2025-01-05 5:56 ` [PATCH 12/59] Check TZif files more carefully Paul Eggert
2025-01-05 5:56 ` [PATCH 13/59] Remove alignment assumption from __tzfile_read Paul Eggert
2025-01-05 5:56 ` [PATCH 14/59] Treat oddball UTC offset strings as zero Paul Eggert
2025-01-05 5:56 ` [PATCH 15/59] Simplify __tz_compute Paul Eggert
2025-01-05 5:56 ` [PATCH 16/59] Improve performance in 2 BC Paul Eggert
2025-01-05 5:56 ` [PATCH 17/59] Don’t mishandle years < 1970 in compute_change Paul Eggert
2025-01-05 5:56 ` [PATCH 18/59] Match RFC 9636 names Paul Eggert
2025-01-05 5:56 ` [PATCH 19/59] Trivial tzset_internal speedup Paul Eggert
2025-01-05 5:56 ` [PATCH 20/59] Fix obscure bug when stdoffset == dstoffset Paul Eggert
2025-01-05 5:56 ` [PATCH 21/59] Document assumption that NO_DST == 0 Paul Eggert
2025-01-05 5:56 ` [PATCH 22/59] __use_tzfile is boolean Paul Eggert
2025-01-05 5:56 ` Paul Eggert [this message]
2025-01-05 5:56 ` [PATCH 24/59] Stop using zic's -y option Paul Eggert
2025-01-05 5:57 ` [PATCH 25/59] Fix mishandling of default DST rule Paul Eggert
2025-01-05 5:57 ` [PATCH 26/59] Simplify treatment of missing and empty TZ Paul Eggert
2025-01-05 5:57 ` [PATCH 27/59] TZ="" always means UTC sans leap seconds Paul Eggert
2025-01-05 5:57 ` [PATCH 28/59] Prefer "UTC" for UTC Paul Eggert
2025-01-05 5:57 ` [PATCH 29/59] Simplify setting tz_rules to UTC Paul Eggert
2025-01-05 5:57 ` [PATCH 30/59] Update tzname etc. even if TZ is unchanged Paul Eggert
2025-01-05 5:57 ` [PATCH 31/59] "POSIX TZ" -> "proleptic TZ" Paul Eggert
2025-01-05 5:57 ` [PATCH 32/59] Reject invalid TZ strings in TZif files Paul Eggert
2025-01-05 5:57 ` [PATCH 33/59] Reject TZif files containing '\0' in TZ string Paul Eggert
2025-01-05 5:57 ` [PATCH 34/59] mktime should not consult 'daylight' Paul Eggert
2025-01-05 5:57 ` [PATCH 35/59] Remove __use_tzfile Paul Eggert
2025-01-05 5:57 ` [PATCH 36/59] Remove arbitrary limit on TZ, TZDIR lengths Paul Eggert
2025-01-05 5:57 ` [PATCH 37/59] Tighten setuid TZif file name check Paul Eggert
2025-01-05 5:57 ` [PATCH 38/59] Avoid a malloc in __tzfile_read Paul Eggert
2025-01-05 5:57 ` [PATCH 39/59] Free earlier " Paul Eggert
2025-01-05 5:57 ` [PATCH 40/59] Improve __tzfile_read TZ="" comment Paul Eggert
2025-01-05 5:57 ` [PATCH 41/59] Refactor enum tz_rule_type Paul Eggert
2025-01-05 5:57 ` [PATCH 42/59] __offtime now returns struct tm * Paul Eggert
2025-01-05 5:57 ` [PATCH 43/59] Fix overflow checking in offtime Paul Eggert
2025-01-05 5:57 ` [PATCH 44/59] Handle TZif time type 0 correctly Paul Eggert
2025-01-05 5:57 ` [PATCH 45/59] Remove invalid tzset tests from tst-bz29951.c Paul Eggert
2025-01-05 5:57 ` [PATCH 46/59] tzset, not localtime, now parses TZif TZ spec Paul Eggert
2025-01-05 5:57 ` [PATCH 47/59] Minor compute_change widening tweak Paul Eggert
2025-01-05 5:57 ` [PATCH 48/59] Minor SECSPERDAY " Paul Eggert
2025-01-05 5:57 ` [PATCH 49/59] Remove leap-second goto from __tzfile_compute Paul Eggert
2025-01-05 5:57 ` [PATCH 50/59] Remove use_last label " Paul Eggert
2025-01-05 5:57 ` [PATCH 51/59] Refactor ‘if’ in __tzfile_compute Paul Eggert
2025-01-05 5:57 ` [PATCH 52/59] Refactor localtime " Paul Eggert
2025-01-05 5:57 ` [PATCH 53/59] Refactor post-transition-table ‘if’ Paul Eggert
2025-01-05 5:57 ` [PATCH 54/59] Refactor __tzfile_compute to avoid two gotos Paul Eggert
2025-01-05 5:57 ` [PATCH 55/59] Refactor __tzfile_compute index local Paul Eggert
2025-01-05 5:57 ` [PATCH 56/59] mktime: prefer bool to int Paul Eggert
2025-01-05 5:57 ` [PATCH 57/59] mktime: port __mktime64 locking to Gnulib Paul Eggert
2025-01-05 5:57 ` [PATCH 58/59] mktime: improve tm_isdst heuristic Paul Eggert
2025-01-05 5:57 ` [PATCH 59/59] time: test DST adjustment for DST-less zones Paul Eggert
2025-01-07 8:59 ` [PATCH v2 0/4] mktime tm_isdst compatibility improvements Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250105055750.1668721-24-eggert@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).