From patchwork Sun Jan 5 05:56:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 104066 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55F22385841C for ; Sun, 5 Jan 2025 06:20:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.cs.ucla.edu (mail.cs.ucla.edu [131.179.128.66]) by sourceware.org (Postfix) with ESMTPS id 9481F3858D38 for ; Sun, 5 Jan 2025 05:59:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9481F3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.ucla.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9481F3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=131.179.128.66 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736056757; cv=none; b=TDXs8q0xJtsg4LGdpKlOxgPW45ATOp/L5ytZQzeYN+fIwv6YzznoD6KwkElzctH4y3RwUKTMXNQ4jnT6eYdYIWXB/Vt8bWRU0Ct3HPk0dftGN+aRbShHxJnS3L8bwr6G3ROGBVWgeJdSQyvpPLOIT49wCQrC8Ls8L+oI2nBnsgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736056757; c=relaxed/simple; bh=+HP8a+wGPnE/fmJgyS3DZu2Gh6mDYQazYGbY5VLnVew=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PYUM+Ft3hCmYwxzC4A792/CUQIkAybqSmyHjvfiHXiHa8lVjxqTK/a8CUEGnW69cBNEUUEMzSe4ABd+KhRzzRBEPScQnZpWF5WsdP9bnWyRbmWn0AnzuqeVDxjMRMCDtDkejxRP46HMqDdxzETOBgYZpk/kTdJTCc+bRhioBNEk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9481F3858D38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=cs.ucla.edu header.i=@cs.ucla.edu header.a=rsa-sha256 header.s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C header.b=ckOZwogX Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 175CB3C123848 for ; Sat, 4 Jan 2025 21:59:12 -0800 (PST) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id d-2hKM7l-CKU; Sat, 4 Jan 2025 21:59:11 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id C2E423C123843; Sat, 4 Jan 2025 21:59:11 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu C2E423C123843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1736056751; bh=Ongf2UJYbhQm5fEd8qmaXoLGhtvl16VnOdpJLSZblEk=; h=From:To:Date:Message-ID:MIME-Version; b=ckOZwogXsfiEr4kog5Fz8Zq6aa3lJC7KYOHJAc8D20tjlLwVWG9MVyed/TgLC8N0H qYOlfFe3x23/hLh/WsU3YJFPcPS+ElXwCIhUokJgLbw+IQFUTU0iKZOkYBB/R0g9zs zgaQ0iIhPNi+X9hBpZubAladfQihQeHrcmeh1nbZaYqZIsBtCNHG1Zc/Fyo98nTYjO IUvcTjrvzITEeimNQT/jYbfi2aRsLhxfZIpa41V6EjLz5e80sCcqi072A9/AdIHGZz pZ/8YTk4SjHq2X26CtXga2BMrwXaNCxQjl1J+jFWgKjBIOj4mEfmnVMMvuvU7LQPZM 5w2mzbco7Wm+A== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id f_oQEk-kGJCR; Sat, 4 Jan 2025 21:59:11 -0800 (PST) Received: from wing.home (unknown [47.154.28.214]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id ABC563C082EB9; Sat, 4 Jan 2025 21:59:11 -0800 (PST) From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH 23/59] Minor tzfile.c clarity improvements Date: Sat, 4 Jan 2025 21:56:58 -0800 Message-ID: <20250105055750.1668721-24-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <01207110-bd60-46ae-9c08-fb39c2011067@cs.ucla.edu> References: <01207110-bd60-46ae-9c08-fb39c2011067@cs.ucla.edu> MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org * 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))