|
|
|
|
|
by sgarland
609 days ago
|
|
> Premature optimiiation is about manually unrolling loops or doing inline assembly - things any modern compiler can do for you automatically. If compilers consistently did this, projects like ffmpeg wouldn’t need to sprinkle assembly into their code base. And yet. |
|
No compiler is perfect, if you need the best performance you need to run a profiler and see where the real bottlenecks are. I'm not sure if ffmpeg really needs to do that, but I trust they ran a profiler and showed it was helpful (cynically: at least at that time with the compilers they had then, though I expect they do this often), and thus it wasn't premature optimization.
Regardless, compilers mostly get this right enough that few people bother with that type of optimization. Thus almost nobody even knows what premature optimization is and so think the wrong thing. Premature optimization is not an excuse to choose a O(n) algorithm when an O(1) exists or some such.