From Jason Turner
Watch on YouTube

Summary

This episode examines how Return Value Optimization (RVO) applies to trivial types like arrays, showing significant performance impacts. Jason demonstrates that even for trivially-copyable objects, the compiler's ability to eliminate copies matters greatly for performance. Through benchmarks comparing three implementation approaches, he shows that small composable functions typically provide the best performance by enabling guaranteed RVO, while naive implementations that construct multiple objects can be twice as slow. The episode also highlights compiler differences, with Clang consistently applying optimization in more cases than GCC.

Resources

Tags