Re: Faster StrNCpy
От | Bruce Momjian |
---|---|
Тема | Re: Faster StrNCpy |
Дата | |
Msg-id | 200610030001.k9301Pn20897@momjian.us обсуждение исходный текст |
Ответ на | Re: Faster StrNCpy (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
Tom Lane wrote: > Alvaro Herrera <alvherre@commandprompt.com> writes: > > You'll notice that it iterates once per char. Between that and the > > strlen() call in Tom's version, not sure which is the lesser evil. > > Yeah, I was wondering that too. My code would require two scans of the > source string (one inside strlen and one in memcpy), but in much of our > usage the source and dest should be reasonably well aligned and one > could expect memcpy to be using word rather than byte operations, so you > might possibly make it back on the strength of fewer write cycles. And > on the third hand, for short source strings none of this matters and > the extra function call involved for strlen/memcpy probably dominates. > > I'm happy to just use the OpenBSD version as a src/port module. > Any objections? I found this URL about the function history of strlcpy(): http://www.gratisoft.us/todd/papers/strlcpy.html I added the URL to port/strlcpy.c. -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
В списке pgsql-hackers по дате отправления: