Re: [PATCH] Use memchr in _IO_new_file_xsputn
Florian Weimer <[email protected]>
| Newsgroups | gmane.comp.lib.glibc.alpha |
|---|---|
| Message-ID | <[email protected]> |
* Adhemerval Zanella Netto: > On 11/06/26 14:42, Bernhard Rosenkränzer wrote: >> Use memchr instead of implementing a bytewise lookup, this should be > > I think you meant memrchr here. > >> slightly faster and more readable >> >> Signed-off-by: Bernhard Rosenkränzer <[email protected]> >> --- >> libio/fileops.c | 12 ++++-------- >> 1 file changed, 4 insertions(+), 8 deletions(-) >> >> diff --git a/libio/fileops.c b/libio/fileops.c >> index 9348d7c3a1..a614e7c528 100644 >> --- a/libio/fileops.c >> +++ b/libio/fileops.c >> @@ -1290,15 +1290,11 @@ _IO_new_file_xsputn (FILE *f, const void *data, size_t n) >> count = f->_IO_buf_end - f->_IO_write_ptr; >> if (count >= n) >> { >> - const char *p; >> - for (p = s + n; p > s; ) >> + const char *p = memrchr (s, '\n', n); > > You should use __memrchr within glibc, otherwise you will see a > elf/check-localplt failure. Bernhard, would you be able to send updated patch? Thanks, Florian