Chapter 3.3
C.90: Rely on constructors and assignment operators, not memset
and memcpy
Chasing maximum performance
C++ has a proud reputation for bare metal performance. Other languages have come and gone, trying to take the performance crown from C++, but still it remains the go-to language for zero-overhead abstractions. It has inherited this pedigree from C, which offers some very efficient library functions. Some of these can be implemented as single processor instructions.
For example, consider double floor(double arg)
. This function lives in header <cmath>
and will return the largest integer value not greater than arg
. There is a sin-gle x86 instruction that will do this for you, called ROUNDSD
. A call to floor
in the hands of a smart ...
Get Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code 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.