bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algo


From: Bruno Haible
Subject: Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm
Date: Wed, 28 Jul 2010 23:32:29 +0200
User-agent: KMail/1.9.9

Pádraig Brady wrote:
> I would suggest a new function due to the
> way I see this function called most often.
> 
> /* definitely not sure of this name */
> uint8_t *
> u8_str_u8_chr (const uint8_t *s, const uint8_t *c, size_t size)
> {
>   switch (size):
>     {
>     case 1:
>       return (uint8_t *) strchr ((const char *) s, *c);
>     case 2:
>       //use logic from current u8_strchr()
>     case 3:
>       ...
>     case 4:
>       ...
>     }
> }
> ...
> while ((f=u8_str_u8_chr (s, "–", 3));

Such an API does not appear very robust to me: it is quite easy to
mistakenly pass a string consisting of more or less than 1 character as
second argument. If the argument to be searched for is given as an
UTF-8 string rather than as an ucs4_t, I would better recommend to use
the u8_strstr function.

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]