C++

Lazy Construction in C++

Performance optimization often has to strike a delicate balance between competing forces. This is perhaps
why it is referred to as optimization as opposed to performance maximization. Performance optimization
often requires the sacrifice of some other software goal. Important goals such as flexibility, maintainability,
cost, and reuse must often give way to the demand for performance. It is […]


Constructors and Destructors in C++

In an ideal world, there would never be a chapter dedicated to the performance implications of constructors
and destructors. In that ideal world, constructors and destructors would have no overhead. They would
perform only mandatory initialization and cleanup, and the average compiler would inline them. C code
such as
{
struct X x1;
init(&x1);

cleanup(&x1);
}
would be accomplished in C++ by:
{
X x1;

}
and the […]