From: "Érico Nogueira" <ericonr@disroot.org>
To: libc-alpha@sourceware.org
Cc: "Érico Nogueira" <ericonr@disroot.org>
Subject: [PATCH 1/3] misc: use _fitoa_word to implement __fd_to_filename.
Date: Mon, 3 May 2021 22:51:50 -0300 [thread overview]
Message-ID: <20210504015152.31064-1-ericonr@disroot.org> (raw)
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 <assert.h>
#include <string.h>
+#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
next reply other threads:[~2021-05-04 1:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 1:51 Érico Nogueira [this message]
2021-05-04 1:51 ` [PATCH 2/3] linux: use fd_to_filename instead of _fitoa_word in ttyname_r Érico Nogueira
2021-05-04 13:18 ` Adhemerval Zanella
2021-05-04 1:51 ` [PATCH 3/3] linux: implement ttyname as a wrapper around ttyname_r Érico Nogueira
2021-05-04 16:37 ` Adhemerval Zanella
2021-05-04 16:43 ` Adhemerval Zanella
2021-05-07 17:21 ` Adhemerval Zanella
2021-05-07 19:20 ` Érico Nogueira
2021-05-04 13:18 ` [PATCH 1/3] misc: use _fitoa_word to implement __fd_to_filename Adhemerval Zanella
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=20210504015152.31064-1-ericonr@disroot.org \
--to=ericonr@disroot.org \
--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).