aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉrico Nogueira <ericonr@disroot.org>2021-05-03 22:51:50 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-05-07 13:54:36 -0300
commit330001202ada53dcf3de81f95edc2616f8d75c68 (patch)
tree2556575e81b462a3ebe09a260b07ca79b4df3108
parentf13fb81ad3159543741e9132685335002a6d5df2 (diff)
downloadglibc-330001202ada53dcf3de81f95edc2616f8d75c68.zip
glibc-330001202ada53dcf3de81f95edc2616f8d75c68.tar.gz
glibc-330001202ada53dcf3de81f95edc2616f8d75c68.tar.bz2
misc: use _fitoa_word to implement __fd_to_filename.
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. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
-rw-r--r--misc/fd_to_filename.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/misc/fd_to_filename.c b/misc/fd_to_filename.c
index 86a1a1a..20c2014 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;
}