From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id 44E63385783D for ; Tue, 4 May 2021 01:52:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 44E63385783D Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 5CE4B53ADE; Tue, 4 May 2021 03:52:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xstZwCNoTOgj; Tue, 4 May 2021 03:52:07 +0200 (CEST) From: =?UTF-8?q?=C3=89rico=20Nogueira?= To: libc-alpha@sourceware.org Cc: =?UTF-8?q?=C3=89rico=20Nogueira?= Subject: [PATCH 1/3] misc: use _fitoa_word to implement __fd_to_filename. Date: Mon, 3 May 2021 22:51:50 -0300 Message-Id: <20210504015152.31064-1-ericonr@disroot.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2021 01:52:13 -0000 In a default build for x86_64, size decreased by 24 bytes: 1883294 to 1883270. Aditionally, avoids repeating the number printing logic in multiple places. --- misc/fd_to_filename.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/misc/fd_to_filename.c b/misc/fd_to_filename.c index 86a1a1acc2..20c2014903 100644 --- a/misc/fd_to_filename.c +++ b/misc/fd_to_filename.c @@ -20,6 +20,7 @@ #include #include +#include <_itoa.h> char * __fd_to_filename (int descriptor, struct fd_to_filename *storage) @@ -28,11 +29,7 @@ __fd_to_filename (int descriptor, struct fd_to_filename *storage) char *p = mempcpy (storage->buffer, FD_TO_FILENAME_PREFIX, strlen (FD_TO_FILENAME_PREFIX)); + *_fitoa_word (descriptor, p, 10, 0) = '\0'; - for (int d = descriptor; p++, (d /= 10) != 0; ) - continue; - *p = '\0'; - for (int d = descriptor; *--p = '0' + d % 10, (d /= 10) != 0; ) - continue; return storage->buffer; } -- 2.31.1