[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16544: Optimazation for is_mb_middle
From: |
Paul Eggert |
Subject: |
bug#16544: Optimazation for is_mb_middle |
Date: |
Tue, 28 Jan 2014 10:37:42 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
Thanks for the further patch. Some comments:
+ if (!mbsinit (&mbs))
+ memset (&mbs, 0, sizeof mbs);
Why bother with mbsinit? Just do the memset, or better yet declare and
initialize mbs here.
+ mbclen_guess[i] = mbrlen ((const char *) &i, 1, &mbs);
This assumes a little-endian machine, which is not portable. Please use
something like this instead:
for (i = CHAR_MIN; i <= CHAR_MAX; i++)
{
char c = i;
unsigned char uc = i;
mbstate_t mbs = { 0 };
mbclen_guess[uc] = mbrlen (&c, 1, &mbs);
}
Here I'm using a style that avoids casts, as casts in general can be
dangerous.
A minor question about naming: in what sense is mbclen_guess a guess?
It doesn't seem to be guessing anything. Perhaps rename it to mbclen_cache?