ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
> ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes:
>> There are 10 instances of this exact loop scattered around the codebase.
>> Is it worth it turning it into a static inline function?
> Something like the attached, maybe?
Meh. The trouble with this is that the call sites don't all declare
the pointer variable the same way. While the written-out loops can
look the same regardless, a function can only accommodate one choice
without messy casts. For my money, the notational savings here is
small enough that the casts really discourage doing anything.
So if we wanted to do this, I'd think about using a macro:
#define strip_relabeltype(nodeptr) \
while (nodeptr && IsA(nodeptr, RelabelType))
nodeptr = ((RelabelType *) nodeptr)->arg
...
strip_relabeltype(em_expr);
...
Since the argument would have to be a variable, the usual
multiple-reference hazards of using a macro don't seem to apply.
(Probably the macro could do with "do ... while" decoration
to discourage any syntactic oddities, but you get the idea.)
regards, tom lane