The least amount of work a program can do to accomplish a certain task is no work at all. Free stuff is great. Similarly, the fastest way to allocate and deallocate memory is this—don't. Local buffer optimization is a way to get something for nothing; in this case, to get some memory for no additional computing cost.
Introducing local buffer optimization
The main idea
To understand local buffer optimization, you have to remember that memory allocations do not happen in isolation. Usually, if a small amount of memory is needed, the allocated memory is used as a part of some data structure. For example, let's consider a very simple character string:
class simple_string {
public:
simple_string() : s_()...