https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120422

Simon Sobisch <simonsobisch at gnu dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simonsobisch at gnu dot org

--- Comment #4 from Simon Sobisch <simonsobisch at gnu dot org> ---
Just stumbled over this and agree for this specific change shown may not be
that reasonable.

Note: I do know that optimising one part in GnuCOBOL in a similar way did help
a slightly with performance, but in this case:

* the name was matched often (may be the case here as well)
* the new code could use something like `const size_t len = strlen (name)` and
that len is then used multiple times
* that also allowed to change from if/else with strcmp to a switch (len) and
then only check the specific ones within the case

Note: for less complexity and when not using the explicit len-switch you can
also use a macro doing   memcmp(name,x,sizeof(x)-1).

The biggest performance gain here is likely something else: instead of passing
the name like "__gg__when_compiled" through the stages, try to use a token
"function" with an assigned "enum func_type" and use a switch (or comparison)
on the enum - less data passed through the stages, less "expensive"
comparisons, no chance for typos, easier reference-check and much more clear
code.

Reply via email to