Re: strncmp->memcmp when we know the shorter length
От
Gurjeet Singh
Тема
Re: strncmp->memcmp when we know the shorter length
Дата
Msg-id
AANLkTi=Fo9-ppsGYE5qdEfaWSNDst6VCumc1SPXvhoT_@mail.gmail.com
Ответ на
Re: strncmp->memcmp when we know the shorter length (Robert Haas)
Список
Дерево обсуждения
strncmp->memcmp when we know the shorter length Noah Misch <noah@leadboat.com>
Re: strncmp->memcmp when we know the shorter length Robert Haas <robertmhaas@gmail.com>
Re: strncmp->memcmp when we know the shorter length Gurjeet Singh <singh.gurjeet@gmail.com>
Re: strncmp->memcmp when we know the shorter length Robert Haas <robertmhaas@gmail.com>
Re: strncmp->memcmp when we know the shorter length Tom Lane <tgl@sss.pgh.pa.us>
Re: strncmp->memcmp when we know the shorter length Robert Haas <robertmhaas@gmail.com>
Re: strncmp->memcmp when we know the shorter length Tom Lane <tgl@sss.pgh.pa.us>
Re: strncmp->memcmp when we know the shorter length Gurjeet Singh <singh.gurjeet@gmail.com>
Re: strncmp->memcmp when we know the shorter length Robert Haas <robertmhaas@gmail.com>
Re: strncmp->memcmp when we know the shorter length Noah Misch <noah@leadboat.com>
On Tue, Dec 21, 2010 at 6:24 PM, Robert Haas <robertmhaas@gmail.com> wrote:
Doesn't this risk accessing bytes beyond the shorter string? Look at the warning above the StrNCpy(), for example.
This is a good idea. I will check this over and commit it.On Mon, Dec 20, 2010 at 1:10 PM, Noah Misch <noah@leadboat.com> wrote:
> When the caller knows the smaller string length, memcmp and strncmp are
> functionally equivalent. Since memcmp need not watch each byte for a NULL
> terminator, it often compares a CPU word at a time for better performance. The
> attached patch changes use of strncmp to memcmp where we have the length of the
> shorter string. I was most interested in the varlena.c instances, but I tried
> to find all applicable call sites. To benchmark it, I used the attached
> "bench-texteq.sql". This patch improved my 5-run average timing of the SELECT
> from 65.8s to 56.9s, a 13% improvement. I can't think of a case where the
> change should be pessimal.
Doesn't this risk accessing bytes beyond the shorter string? Look at the warning above the StrNCpy(), for example.
Regards,
--
gurjeet.singh
@ EnterpriseDB - The Enterprise Postgres Company
http://www.EnterpriseDB.com
singh.gurjeet@{ gmail | yahoo }.com
Twitter/Skype: singh_gurjeet
Mail sent from my BlackLaptop device
В списке pgsql-hackers по дате отправления
От: Alvaro Herrera
Дата:
От: Rob Wultsch
Дата: