|
|
|
|
|
by nanolith
2723 days ago
|
|
> Do you also write all your functions to pass large inputs by value until a profiler says you can pass a const reference? No, but neither do I pass types that fit in a native integer by const reference because copies should be avoided at all costs. There is always a tradeoff. > Some implementation details are so well understood that you really don't need a profiler to do what is probably the right thing by default. Avoiding any and all indirection at all costs is not one of these. The pImpl pattern, much like virtual methods, function pointers, etc., are each tools. Indirection is a trade-off that is either worth the expense in cache misses or is not. The cost is not so cut and dried as others in the thread have assumed. |
|
"Any and all"? Perhaps not. However, I believe the context here was standard library headers. Those are full of small, often-used functions, so avoiding idioms based on indirection such as pImpl is about as close to a black and white rule as you're ever going to find in the programming world.