* Re: [PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s)
@ 2023-09-25 13:18 James
2023-09-25 13:40 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: James @ 2023-09-25 13:18 UTC (permalink / raw)
To: cristian; +Cc: libc-alpha, James
> Did you fill out a compiler enhancement request ? AFAIK it should always
> do this transformation..(unless I'm missing an special case)
It doesn't on GCC 6.3 (and lower I would assume).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s)
2023-09-25 13:18 [PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s) James
@ 2023-09-25 13:40 ` Andreas Schwab
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2023-09-25 13:40 UTC (permalink / raw)
To: James; +Cc: cristian, libc-alpha
On Sep 25 2023, James wrote:
> It doesn't on GCC 6.3 (and lower I would assume).
Compiling glibc with such an old version, while still supported, is not
recommended.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s)
2023-09-25 8:19 James Tirta Halim
@ 2023-09-25 11:57 ` Cristian Rodríguez
0 siblings, 0 replies; 4+ messages in thread
From: Cristian Rodríguez @ 2023-09-25 11:57 UTC (permalink / raw)
To: James Tirta Halim; +Cc: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]
On Mon, Sep 25, 2023 at 5:23 AM James Tirta Halim <tirtajames45@gmail.com>
wrote:
> ---
> 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
>
>
Did you fill out a compiler enhancement request ? AFAIK it should always
do this transformation..(unless I'm missing an special case)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s)
@ 2023-09-25 8:19 James Tirta Halim
2023-09-25 11:57 ` Cristian Rodríguez
0 siblings, 1 reply; 4+ messages in thread
From: James Tirta Halim @ 2023-09-25 8:19 UTC (permalink / raw)
To: libc-alpha; +Cc: James Tirta Halim
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-25 13:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-25 13:18 [PATCH] ftw.c: strchr(s, '\0') isn't always optimized to s + strlen(s) James
2023-09-25 13:40 ` Andreas Schwab
-- strict thread matches above, loose matches on Subject: below --
2023-09-25 8:19 James Tirta Halim
2023-09-25 11:57 ` Cristian Rodríguez
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).