From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: appendStringInfo vs appendStringInfoString |
Date: | 2013-09-28 11:40:47 |
Message-ID: | CAApHDvqoO1+23ivcS0a_=tg7Wbp7USetmhZ-N-2mRXEfdnbP=g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Sep 28, 2013 at 11:11 PM, Heikki Linnakangas <
hlinnakangas(at)vmware(dot)com> wrote:
> On 28.09.2013 12:44, David Rowley wrote:
>
>> The macro for test 4 was as follows:
>> #define appendStringInfoStringConst(**buf, s) appendBinaryStringInfo(buf,
>> (s), sizeof(s)-1)
>>
>
> If that makes any difference in practice, I wonder if we should just do:
>
> #define appendStringInfoString(buf, s) appendBinaryStringInfo(buf, (s),
> strlen(s))
>
> With a compiler worth its salt, the strlen(s) will be optimized into a
> constant, if s is a constant. If it's not a constant, we'll just end up
> calling strlen(), like appendStringInfoString would anyway. That would turn
> a single function call into two in all of the non-constant callsites,
> though, bloating the code, so it might not be a win overall.
>
>
Nice idea.
I quick test shows that this works with the MS compiler I'm using on
windows.
appendStringInfoString in 0.249000 sec <---
appendStringInfo with %s in 1.135000 sec
appendStringInfo in 1.295000 sec
appendStringInfoStringConst with in 0.245000 sec
Regards
David
> - Heikki
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2013-09-28 11:44:22 | Re: appendStringInfo vs appendStringInfoString |
Previous Message | Heikki Linnakangas | 2013-09-28 11:11:29 | Re: appendStringInfo vs appendStringInfoString |