This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/17087] Implement memcasemem()


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]