Inlining question

John Meacham john at
Sun Apr 3 18:45:15 EDT 2005

On Sun, Apr 03, 2005 at 02:38:30PM +0100, Ian Lynagh wrote:
> Why does it matter whether the definition is in the current file or is
> imported from the standard libraries?

The issue is not whether it is imported but rather how many uses the
function has. The routine declared in the standard library can be called
from an arbitrary number of places so if it were to inline it everywhere
it might duplicate too much code. However, your locally defined version
is only used once, so ghc knows it can inline it without code
duplication. However, this dramatic improvement perhaps means that ghc's
default inlining parameters need to be tweaked?  

There are several things ghc takes into account when deciding whether to
inline a function, the paper "Secrets of the GHC Inliner" is quite good.


John Meacham - ⑆⑆john⑈ 

More information about the Glasgow-haskell-users mailing list