Minimizing inlines
While inline functions speed execution,
they may also increase executable sizes,
so that as more inlines are added,
the time saved by avoiding function linkage is
eventually swamped by the increase in text size.
We therefore limited our use of
inlines to two cases:
-
when the amount of inline code is small
-
when the functionality of a frequently-used function can be divided
into two parts: a simple case,
which is done inline, and a complicated case, which
requires a function call.
We talk more about this case in the section
``Using inline functions''.
The following example from
Block(C++)
illustrates
both cases:
Block.h
template <class T> class Block {
private:
unsigned n;
unsigned grow(unsigned);
...
public:
// example of (1)
unsigned size() const { return n; }
// example of (2)
int reserve(unsigned k) {
return k<n || grow(k);
}
...
}
Next topic:
Minimizing linkage dependencies
Previous topic:
Executable size
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005