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(3C++) 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

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004