any issue replacing pointer with unique pointer in this example? #1669
-
hi, in this example is replacing a mistake ? I guess just using a I just want to make sure because there are a lot of pieces rolling. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The size of a pointer is 8 bytes, same for unique_ptr. The size of std::string is 32 bytes. The size of std::function is 32 bytes. This means that you'd pay allocation cost in your fast path with your change. The whole point is to have a fast fast path and a slow slow path. Whatever you do (unique_ptr is probably fine), you don't want to incur a cost in your fast path. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot, great lib |
Beta Was this translation helpful? Give feedback.
The size of a pointer is 8 bytes, same for unique_ptr. The size of std::string is 32 bytes. The size of std::function is 32 bytes.
This means that you'd pay allocation cost in your fast path with your change. The whole point is to have a fast fast path and a slow slow path. Whatever you do (unique_ptr is probably fine), you don't want to incur a cost in your fast path.