Re: const correctness - Mailing list pgsql-hackers

From Tom Lane
Subject Re: const correctness
Date
Msg-id 20583.1320874683@sss.pgh.pa.us
Whole thread Raw
In response to Re: const correctness  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: const correctness
Re: const correctness
List pgsql-hackers
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> If people aren't inclined to support this on the grounds of API
> clarity, maybe we should do some sort of benchmark run while we have
> a patch which applies cleanly before writing off the possible
> performance impact, but I'm not sure what makes a good stress-test
> for the affected code.

I don't doubt that just duplicating macros and inlineable functions is
a wash performance-wise (in fact, in principle it shouldn't change
the generated code at all).  My objection is the one Robert already
noted: it takes extra brain cells to remember which function/macro
to use, and I have seen not a shred of evidence that that extra
development/maintenance effort will be repaid.

I think that "const" works materially better in C++ where you can
overload foo(struct *) and foo(const struct *) and let the compiler sort
out which is being called.  In C, the impedance match is a lot worse,
so you have to pick and choose where const is worth the trouble.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Daniel Farina
Date:
Subject: Re: 9.1.2 ?
Next
From: Simon Riggs
Date:
Subject: Re: heap vacuum & cleanup locks