r/cpp • • Feb 16 '26

Favorite optimizations ??

I'd love to hear stories about people's best feats of optimization, or something small you are able to use often!

135 Upvotes

185 comments sorted by

View all comments

Show parent comment

1

u/jmonschke Mar 17 '26

That is why I try to minimize dynamic allocations in general, and keep things on the stack, and statically allocated within objects, and pre-allocating space for containers on construction, as much as possible.