[PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s)
James Tirta Halim
tirtajames45@gmail.com
Mon Sep 25 08:19:25 GMT 2023
---
io/ftw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/io/ftw.c b/io/ftw.c
index 742369a2d2..533b4012e5 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -554,7 +554,7 @@ fail:
/* Next, update the `struct FTW' information. */
++data->ftw.level;
- startp = strchr (data->dirbuf, '\0');
+ startp = data->dirbuf + strlen(data->dirbuf):
/* There always must be a directory name. */
assert (startp != data->dirbuf);
if (startp[-1] != '/')
@@ -595,7 +595,7 @@ fail:
while (result == 0 && *runp != '\0')
{
- char *endp = strchr (runp, '\0');
+ char *endp = runp + strlen(runp);
// XXX Should store the d_type values as well?!
result = process_entry (data, &dir, runp, endp - runp, DT_UNKNOWN);
--
2.42.0
More information about the Libc-alpha
mailing list