Use PointerGetDatum(cstring_to_text_with_len()) instead of CStringGetTextDatum() to avoid duplicate strlen

Поиск
Список
Период
Сортировка
От Hou, Zhijie
Тема Use PointerGetDatum(cstring_to_text_with_len()) instead of CStringGetTextDatum() to avoid duplicate strlen
Дата
Msg-id 3430b3f62a3f48368ef219f1a5ff3c28@G08CNEXMBPEKD05.g08.fujitsu.local
обсуждение исходный текст
Ответы Re: Use PointerGetDatum(cstring_to_text_with_len()) instead of CStringGetTextDatum() to avoid duplicate strlen  (Heikki Linnakangas <hlinnaka@iki.fi>)
Список pgsql-hackers
Hi

I found some code like the following:

> StringInfoData s;
> ...
> values[6] = CStringGetTextDatum(s.data);

The length of string can be found in ' StringInfoData.len',
but the macro CStringGetTextDatum will use strlen to count the length again.
I think we can use PointerGetDatum(cstring_to_text_with_len(s.data, s.len)) to improve.

> #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
> text *
> cstring_to_text(const char *s)
> {
>     return cstring_to_text_with_len(s, strlen(s));
> }


There may have more places that can get the length of string in advance,
But that may need new variable to store it ,So I just find all StringInfoData cases.

Best regards,
houzj





Вложения

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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: speed up unicode normalization quick check
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: speed up unicode normalization quick check