3 ms·
Why do you think pass-by-value takes up more memory? The data gets packed on the stack pretty densely, so as long as the data structures are tiny, that shouldn
by pkolaczk 5y ago
Why do you think pass-by-value takes up more memory?
The data gets packed on the stack pretty densely, so as long as the data structures are tiny, that shouldn't be a problem. On the flip side heap allocation is typically prone to some level of fragmentation, which actually does waste memory.
- random9e7de4c1 5y agoI agree with your point for small size data structures. But in general, and in the case of the OP source code, he doesn't even need to copy its arguments to pass them by value, he should pass them via a const reference, and just pass the address.