From: | "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com> |
---|---|
To: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Use PointerGetDatum(cstring_to_text_with_len()) instead of CStringGetTextDatum() to avoid duplicate strlen |
Date: | 2020-10-19 06:32:57 |
Message-ID: | 3430b3f62a3f48368ef219f1a5ff3c28@G08CNEXMBPEKD05.g08.fujitsu.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Attachment | Content-Type | Size |
---|---|---|
0001-prevent-duplicate-strlen.patch | application/octet-stream | 2.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2020-10-19 06:57:28 | Re: speed up unicode normalization quick check |
Previous Message | Peter Eisentraut | 2020-10-19 06:15:56 | Re: speed up unicode normalization quick check |