[PATCH] Move clause_sides_match_join() into pathnode.h

Started by James Hunterabout 2 years ago4 messageshackers
Jump to latest
#1James Hunter
james.hunter.pg@gmail.com

We had two almost-identical copies of the utility function
clause_sides_match_join() -- one in joinpath.c, and one in
analyzejoins.c. Both copies were marked "inline," so we might as well
just move the (inline) function definition into a common header file.
I chose pathnode.h, because it is already #included by both of the .c
files.

This change doesn't help very much, on its own (since the
almost-duplicate functions are both "inline"), but it allows us to use
the same utility function from other source files, without making a
third copy.

James

Attachments:

0001-Move-clause_sides_match_join-into-pathnode.h.patchapplication/octet-stream; name=0001-Move-clause_sides_match_join-into-pathnode.h.patchDownload+37-69
#2David Rowley
dgrowleyml@gmail.com
In reply to: James Hunter (#1)
Re: [PATCH] Move clause_sides_match_join() into pathnode.h

On Thu, 10 Oct 2024 at 08:38, James Hunter <james.hunter.pg@gmail.com> wrote:

We had two almost-identical copies of the utility function
clause_sides_match_join() -- one in joinpath.c, and one in
analyzejoins.c. Both copies were marked "inline," so we might as well
just move the (inline) function definition into a common header file.
I chose pathnode.h, because it is already #included by both of the .c
files.

I'm in favour of the deduplication. pathnode.h seems like a strange
choice. restrictinfo.h seems more suited.

(I really wonder how much the inlining is giving us given that the
function itself calls other non-inlineable functions)

David

#3James Hunter
james.hunter.pg@gmail.com
In reply to: David Rowley (#2)
Re: [PATCH] Move clause_sides_match_join() into pathnode.h

On Wed, Oct 9, 2024 at 5:26 PM David Rowley <dgrowleyml@gmail.com> wrote:

On Thu, 10 Oct 2024 at 08:38, James Hunter <james.hunter.pg@gmail.com> wrote:

We had two almost-identical copies of the utility function
clause_sides_match_join() -- one in joinpath.c, and one in
analyzejoins.c. Both copies were marked "inline," so we might as well
just move the (inline) function definition into a common header file.
I chose pathnode.h, because it is already #included by both of the .c
files.

I'm in favour of the deduplication. pathnode.h seems like a strange
choice. restrictinfo.h seems more suited.

Moved into restrictinfo.h, instead, in next revision. (The only reason
I initially chose pathnode.h is because it was already #included by
the two .c files; I agree, after glancing over restrictinfo.h, that it
seems like a better fit.)

(I really wonder how much the inlining is giving us given that the
function itself calls other non-inlineable functions)

I wondered the same! But, at least the branch can be inlined?

Thanks for looking over the patch,
James

Attachments:

0001-Move-clause_sides_match_join-into-restrictinfo.h.patchapplication/octet-stream; name=0001-Move-clause_sides_match_join-into-restrictinfo.h.patchDownload+38-69
#4David Rowley
dgrowleyml@gmail.com
In reply to: James Hunter (#3)
Re: [PATCH] Move clause_sides_match_join() into pathnode.h

On Fri, 11 Oct 2024 at 04:25, James Hunter <james.hunter.pg@gmail.com> wrote:

Moved into restrictinfo.h, instead, in next revision.

Thanks. Pushed.

(I really wonder how much the inlining is giving us given that the
function itself calls other non-inlineable functions)

I wondered the same! But, at least the branch can be inlined?

Do you mean function call? As far as I see it, that's the only
advantage. There are no branches that can be eliminated from
constant-folding.

I imagine the original version was only inlined to help coax the
compiler into inlining, which I imagine it would have done anyway if
there was just a single usage of the static function. Probably the
analyzejoins.c version just copied the original joinpath.c version. I
didn't check the history to know if that's actually true.

David