Re: [PATCH] Optimize prefixcmp()
- From
- Marco Costalba <mcostalba@gmail.com>
- Date
- Dec 30, 2007, 15:17 UTC
- Message-ID
- <e5bfff550712300717r4512954rbf2516491fc13adc@mail.gmail.com>
- In-Reply-To
- <e5bfff550712300650j2ea70032jaca893b734592184@mail.gmail.com>
On Dec 30, 2007 3:50 PM, Marco Costalba <mcostalba@gmail.com> wrote:
> > If *prefix == "" case is to be considered I vote for your/Johannes > version because it's "better code" (tm). >
Ok this is fast and correct
static inline int prefixcmp(const char *str, const char *prefix)
{
while (*str == *prefix && *prefix)
str++, prefix++;return (*prefix ? *(unsigned const char *)prefix - *(unsigned const char *)str : 0); }
This is the last one, I promise ;-)
Marco