Re: Patch: add conversion from pg_wchar to multibyte

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема Re: Patch: add conversion from pg_wchar to multibyte
Дата
Msg-id 20120529.102742.1942410168809096450.t-ishii@sraoss.co.jp
обсуждение исходный текст
Ответ на Re: Patch: add conversion from pg_wchar to multibyte  (Alexander Korotkov <aekorotkov@gmail.com>)
Список pgsql-hackers
> On Tue, May 22, 2012 at 3:27 PM, Tatsuo Ishii <ishii@postgresql.org> wrote:
> 
>> > Thanks for your comments. They clarify a lot.
>> > But I still don't realize how can we distinguish IS_LCPRV2 and IS_LC2?
>> > Isn't it possible for them to produce same pg_wchar?
>>
>> If LB is in 0x90 - 0x99 range, then they are LC2.
>> If LB is in 0xf0 - 0xff range, then they are LCPRV2.
>>
> 
> Thanks. I rewrote inverse conversion from pg_wchar to mule. New version of
> patch is attached.

[forgot to cc: to the list]

I looked into your patch, especially: pg_wchar2euc_with_len(const
pg_wchar *from, unsigned char *to, int len)

I think there's a small room to enhance the function.
    if (*from >> 24)    {        *to++ = *from >> 24;        *to++ = (*from >> 16) & 0xFF;        *to++ = (*from >> 8)
&0xFF;        *to++ = *from & 0xFF;        cnt += 4;    }
 

Since the function walk through this every single wchar, something like:
    if ((c = *from >> 24))    {        *to++ = c;        *to++ = (*from >> 16) & 0xFF;        *to++ = (*from >> 8) &
0xFF;       *to++ = *from & 0xFF;        cnt += 4;    }
 

will save few cycles(I'm not sure the optimizer produces similar code
above anyway though).
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Uh, I change my mind about commit_delay + commit_siblings (sort of)
Следующее
От: Tom Lane
Дата:
Сообщение: AbortOutOfAnyTransaction is a few bricks shy of a load