Reduce Flexibility

As a domain expert you are often in position to make simplifying assumptions that boost performance.

Often, a Web server needs to know the IP address of the client where the request originated. An IP address is a dotted decimal expression like 9.37.37.205. Initially, for every request, our code allocated heap storage large enough to hold the client IP address. That storage was deallocated at the end of the request handling. Calling new() and delete() for heap memory is expensive. This is particularly bad since you do it for every request. Using memory pools can alleviate the burden, but it is still not as good as eliminating the new() and delete() calls altogether.

If an IP address was potentially unbounded in length, we would ...

Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.