3 ms·
Not optimizing when creating a temporary variable is unfortunate. I sometimes create those for debugging purposes, give them a descriptive name, then leave it
by tcbawo 6y ago
Not optimizing when creating a temporary variable is unfortunate. I sometimes create those for debugging purposes, give them a descriptive name, then leave it in for documentation purposes after the debugging is complete. Typically for me, this isn't the sort of code that executes in a tight loop, so is unlikely to impact performance.
Edit: I agree with the other commenter about taking in a Widget by reference instead of by value in the consume function.
- MontagFTB 6y agoIf the routine is truly going to consume the widget, then you’re paying for a copy within the routine if you take the parameter by reference. Unfortunately that’s just kicking the can down the road. I’d prefer code like this use the move operation to make the code reasonably efficient and maintainable. Then, only after its proven the line is on a critical performance path, it can be further optimized later.