[PATCH] libiberty: d-demangle: use switch instead of if-else

Jeff Law jeffreyalaw@gmail.com
Sun Oct 3 21:55:41 GMT 2021



On 9/29/2021 7:08 PM, Luís Ferreira wrote:
> This patch allows the compiler to efficiently generate jump tables instead of
> using if-else-if.
>
> Signed-off-by: Luís Ferreira <contact@lsferreira.net>
I'm not sure this is terribly useful.  Compilers have the ability to 
analyze the underlying code and make sensible decisions for how to 
implement either form.   So the right metric here is does this make the 
code cleaner/easier to understand.  With just 3 clauses it's hard (for 
me) to make the case that it is considerably cleaner.

Jeff




More information about the Gcc-patches mailing list