DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
The Design of C++ Standard Components

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:

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