3 ms·
It is often too obvious that e.g. O((x+y)^2)-drawing will degrade quickly. There is no point in implementing it slow way, because you'll see the effect in few h
by wruza 10y ago
It is often too obvious that e.g. O((x+y)^2)-drawing will degrade quickly. There is no point in implementing it slow way, because you'll see the effect in few hours and will spend few hours to fix all the places, not mentioning re-architecture cases. 100ms vs. 500ms is non-trivial to predict. O(log(n)) vs. O(n^3) for freely growing n is trivial.
The code that iterates over items and skips on condition isn't any easier to read or detect errors than access via bsearch or similar subroutine. In fact, straightforward code tends to introduce errors. Optimizations and correct naming [and thus centralized control] of routines are pretty close to each other, and when you give a name to get_cached_col_offset(col, last_known_col, last_known_offset) or have explicit caching iterator, the code looks much readable than for(y)-for(x)-everywhere mess with different off-by-ones and overflows in each block.
Where is that line separating dumb code from clean code?
Edit: wording