[Top][All Lists]
[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: |
Pádraig Brady |
Subject: |
Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm |
Date: |
Tue, 27 Jul 2010 17:06:55 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
On 23/07/10 13:03, Paolo Bonzini wrote:
> On 07/23/2010 09:21 AM, Bruno Haible wrote:
>> Otherwise fine, please commit. I can add comments that prove the
>> validity of
>> the code later, after you committed it.
>
> v2 already had large comments that detail the algorithm used and do
> include all the info in the comments you suggested. Feel free to add
> more to it.
>
> I pushed it now, thanks for the review!
I would suggest a new function due to the
way I see this function called most often.
I.E. repeatedly with the same character.
/* 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:
...
}
}
Then that can be called by u8_strchr():
uint8_t *
u8_strchr (const uint8_t *s, ucs4_t uc)
{
if (uc < 0x80)
return (uint8_t *) strchr ((const char *) s, uc);
else
{
uint8_t c[6];
size_t size = u8_uctomb_aux (c, uc, sizeof c);
return u8_str_u8_chr (s, c, size);
}
}
Note these performance and interface suggestions
apply to u8_strrchr() also.
cheers,
Pádraig.
- [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, bonzini, 2010/07/23
- [PATCH v2 1/5] unistr/u*-chr: prepare for multibyte tests, bonzini, 2010/07/23
- [PATCH v2 2/5] unistr/u*-chr: test multibyte sequences, bonzini, 2010/07/23
- [PATCH v2 3/5] unistr/u*-chr: test multibyte sequences more, bonzini, 2010/07/23
- [PATCH v2 4/5] unistr/u*-strchr: add tests, bonzini, 2010/07/23
- [PATCH v2 5/5] unistr/u8-chr, unistr/u8-strchr: use Boyer-Moore like algorithm., bonzini, 2010/07/23
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Bruno Haible, 2010/07/23
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Bruno Haible, 2010/07/28
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Pádraig Brady, 2010/07/29
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Paolo Bonzini, 2010/07/29
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Pádraig Brady, 2010/07/29
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Paolo Bonzini, 2010/07/29
- Message not available
- Message not available
- Re: [PATCH v2 0/5] Speed up uNN_chr and uNN_strchr with Boyer-Moore algorithm, Paolo Bonzini, 2010/07/29