This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/17087] Implement memcasemem()
- From: "kenatmit at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 25 Jun 2014 18:30:18 +0000
- Subject: [Bug libc/17087] Implement memcasemem()
- Auto-submitted: auto-generated
- References: <bug-17087-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=17087
--- Comment #2 from Ken at MIT <kenatmit at gmail dot com> ---
The case conversion can be implemented in SIMD instructions and take less
than one instruction per byte. The same that can be done in strcasestr().
Detecting if a detected byte was after the end can be done using count
leading zeros, a shift and a mask. This is also possible/required in
memmem().
The strcasestr() function can not be used in place of memcasemem() as that
would require adding NULL terminations to both the needle and the haystack,
which is not always possible.
On Wed, Jun 25, 2014 at 12:40 PM, neleai at seznam dot cz <
sourceware-bugzilla@sourceware.org> wrote:
> https://sourceware.org/bugzilla/show_bug.cgi?id=17087
>
> --- Comment #1 from Ondrej Bilka <neleai at seznam dot cz> ---
> On Wed, Jun 25, 2014 at 03:19:01PM +0000, kenatmit at gmail dot com wrote:
> >
> > The of function strstr() has the case-insensitive version strcasestr(),
> but
> > memmem() does not have the case-insensitive version memcasemem().
> >
> > The memcasemem() version would be useful for optimizing some programs.
> For
> > example Suricata intrustion prevetion and detection code.
> >
> That would not help as optimization, a case conversion is more expensive
> than detecting end condition and in vectorized implementations it is
> faster to detect terminating null than add special casing if detected
> byte was before or after end.
>
> --
> You are receiving this mail because:
> You reported the bug.
>
--
You are receiving this mail because:
You are on the CC list for the bug.