3 ms·
Two things: 1) It's a memory allocation, scanning data structures, possibly involving some thread-locking or even a system call. A single check is cheap. If
by lallysingh 17y ago
Two things:
1) It's a memory allocation, scanning data structures, possibly involving some thread-locking or even a system call. A single check is cheap. If you want to keep the CPU happy the 99% of the time, put the most likely case first, so the CPU doesn't have to jump. Speculation should help mitigate the rest.
2) A good reason why operator new() throws by default.