appendStringInfoString() micro-opt - Mailing list pgsql-patches

From Neil Conway
Subject appendStringInfoString() micro-opt
Date
Msg-id 87y8rwae2d.fsf@mailbox.samurai.com
Whole thread Raw
Responses Re: appendStringInfoString() micro-opt
List pgsql-patches
This patch replaces a bunch of call sites of appendStringInfo() with
appendStringInfoString(). (For those without the code in front of
you, the difference between these two functions is that the former
takes a sprintf-style format string and a variable list of arguments,
whereas the latter just takes a single NUL-terminated string;
therefore, the latter is faster if you're just appending a single
string to the buffer).

For the sake of minimizing how much of my time I've wasted if someone
objects, this patch only changes a portion of the call sites that
could be changed; I'll do the rest before committing the patch.

I was tempted to make appendStringInfoString() a macro, since (a) it's
just one line of code (b) I'd expect plenty of compilers to be smart
enough to optimize-out a strlen() on a string-literal arg. The
downside is that it would require that appendStringInfoString()
evaluate its arguments more than once. Any comments on whether this is
worth doing?

Unless anyone objects, I intend to apply the full version of this
patch within 48 hours.

-Neil

Attachment

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Show function parameter names in information schema
Next
From: Neil Conway
Date:
Subject: next draft of list rewrite