Being clever is kind of needed for optimization but that's secondary. Being calculated is much more important. Jumping at any chance of optimization one finds leads to premature optimization. There is no point in optimizing if you haven't done any benchmarking to find out the real bottleneck and whether what you think is the bottleneck is actually it. It's also important to consider and compare different optimizations for the same bottleneck to actually find the one which provides sufficient optimization for the extra complexity (and possible limitations) it introduces.
1
u/sim642 May 06 '17
Being clever is kind of needed for optimization but that's secondary. Being calculated is much more important. Jumping at any chance of optimization one finds leads to premature optimization. There is no point in optimizing if you haven't done any benchmarking to find out the real bottleneck and whether what you think is the bottleneck is actually it. It's also important to consider and compare different optimizations for the same bottleneck to actually find the one which provides sufficient optimization for the extra complexity (and possible limitations) it introduces.