Re: Optimizing empty functions in C

"Ralph Corderoy" <ralph@inputplus.co.uk>
28 Jun 2002 18:08:35 -0400

          From comp.compilers

Related articles
[7 earlier articles]
Re: Optimizing empty functions in C wasowski@data.pl (Andrzej Wasowski) (2002-06-20)
Re: Optimizing empty functions in C wasowski@data.pl (Andrzej Wasowski) (2002-06-20)
Re: Optimizing empty functions in C mlacey@microsoft.com (Mark Lacey \[MSFT\]) (2002-06-20)
Re: Optimizing empty functions in C dnovillo@redhat.com (Diego Novillo) (2002-06-28)
Re: Optimizing empty functions in C snicol@apk.net (Scott Nicol) (2002-06-28)
Re: Optimizing empty functions in C haberg@matematik.su.se (Hans Aberg) (2002-06-28)
Re: Optimizing empty functions in C ralph@inputplus.co.uk (Ralph Corderoy) (2002-06-28)
Re: Optimizing empty functions in C iddw@hotmail.com (Dave Hansen) (2002-06-28)
Re: Optimizing empty functions in C Peter-Lawrence.Montgomery@cwi.nl (Peter L. Montgomery) (2002-06-28)
| List of all articles for this month |

From: "Ralph Corderoy" <ralph@inputplus.co.uk>
Newsgroups: comp.compilers
Date: 28 Jun 2002 18:08:35 -0400
Organization: InputPlus Ltd.
References: 02-06-025
Keywords: C, optimize
Posted-Date: 28 Jun 2002 18:08:34 EDT
Originator: ralph@inputplus.co.uk (Ralph Corderoy)

Hi Andrzej,


> [ about optimizing lots of empty functions ]


Rather than answers your questions, I'll make a suggestion based on
what it sounds like is causing you to ask these questions.


Instead of creating foo0() to foo100(), many of which are just
`return', and pairing them up with non_empty_foo42 flags, consider


        void (*foo[101])(void);


i.e., foo is an array of 101 pointers to functions taking no parameters
and returning nothing.


You can then point multiple elements of foo[] to the same function
definition, and can either treat a null pointer as `the function
doesn't exist because it does nothing', or not use null pointers and
just have your foo_empty() function as before.


Cheers,


Ralph.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.