]> git.draconx.ca Git - cdecl99.git/commit
libcdecl: Combine identifier and struct allocation.
authorNick Bowler <nbowler@draconx.ca>
Sun, 23 Jul 2023 19:06:29 +0000 (15:06 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 23 Jul 2023 19:13:11 +0000 (15:13 -0400)
commit1ef30936f5fdb253b397347b91521455d0c39172
tree611f8c7d7ba65cb05292c8191955c1d0cc60a353
parent93f0fff49d45d0cb36d7f7d9109c4fb56e6ebeab
libcdecl: Combine identifier and struct allocation.

Whenever the parser uses an identifier token, it is always to stuff
it into a newly-allocated declarator or declspec structure.

So we can reduce the amount of work that needs to be done in the
parser actions by by pre-allocating a declarator structure in the
scanner.  By using a union, we can also use this same allocation
for the declspec case.

And by happy accident, some of the structure members are identical
between both cases, and GCC at least recognizes that it doesn't need
to do anything to copy e.g., declarator.u.ident to declspec.ident
within the union.
src/cdecl-internal.h
src/parse-decl.c
src/parse.y
src/scan.l