From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "Érico Nogueira" <ericonr@disroot.org>, libc-alpha@sourceware.org
Subject: Re: [PATCH 1/3] misc: use _fitoa_word to implement __fd_to_filename.
Date: Tue, 4 May 2021 10:18:52 -0300 [thread overview]
Message-ID: <5cea7b3a-0181-adca-799f-e93a40915847@linaro.org> (raw)
In-Reply-To: <20210504015152.31064-1-ericonr@disroot.org>
On 03/05/2021 22:51, Érico Nogueira via Libc-alpha wrote:
> 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.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> 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;
> }
>
prev parent reply other threads:[~2021-05-04 13:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 1:51 Érico Nogueira
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 ` Adhemerval Zanella [this message]
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=5cea7b3a-0181-adca-799f-e93a40915847@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=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).