←back to thread

327 points AareyBaba | 1 comments | | HN request time: 0s | source
Show context
mwkaufma ◴[] No.46183728[source]
TL;DR

- no exceptions

- no recursion

- no malloc()/free() in the inner-loop

replies(9): >>46183820 #>>46183900 #>>46184073 #>>46184113 #>>46184198 #>>46184398 #>>46184472 #>>46184588 #>>46185500 #
jandrewrogers ◴[] No.46183820[source]
i.e. standard practice for every C++ code base I've ever worked on
replies(1): >>46183866 #
DashAnimal ◴[] No.46183866[source]
What industry do you work in? Modern RAII practices are pretty prevalent
replies(2): >>46183904 #>>46184092 #
jandrewrogers ◴[] No.46183904[source]
What does RAII have to do with any of the above?
replies(4): >>46183995 #>>46184069 #>>46184097 #>>46184150 #
WD-42 ◴[] No.46183995[source]
0 allocations after the program initializes.
replies(4): >>46184066 #>>46184067 #>>46184129 #>>46184331 #
1. tialaramex ◴[] No.46184129[source]
RAII doesn't imply allocating.

My guess is that you're assuming all user defined types, and maybe even all non-trivial built-in types too, are boxed, meaning they're allocated on the heap when we create them.

That's not the case in C++ (the language in question here) and it's rarely the case in other modern languages because it has terrible performance qualities.