Re: const correctness
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Cc: "Robert Haas" <robertmhaas@gmail.com>, "Thomas Munro" <munro@ip9.org>, pgsql-hackers@postgresql.org
Date: 2011-11-09T21:38:03Z
Lists: 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