Skip site navigation (1) Skip section navigation (2)

appendStringInfoString() micro-opt

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: appendStringInfoString() micro-opt
Date: 2004-01-25 03:43:06
Message-ID: 87y8rwae2d.fsf@mailbox.samurai.com (view raw or flat)
Thread:
Lists: 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: append-string-opt-3.patch
Description: text/x-patch (17.4 KB)

Responses

pgsql-patches by date

Next:From: Neil ConwayDate: 2004-01-25 04:03:23
Subject: next draft of list rewrite
Previous:From: Tom LaneDate: 2004-01-24 23:45:44
Subject: Re: Show function parameter names in information schema

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group