Any Amount of Computation is Worth It

There are very few specific instructions I can remember being given during my Computer Science course at University. However, one stands out and has stayed with me in the years since:

"Any amount of computation is worth it, to avoid having to draw to the screen."


It's not an exact quote, and my attribution to Dr. Peter Dickman might be nothing more than a hazy recollection, but it's still golden advice.

I've been working on some additions to Blake Seely's MUPhotoView class. In particular, I'm implementing support for drag-reordering the photos in the view. Since the view has to track the user's drag in order to draw the insertion point, it's a performance-critical operation. I don't know about you, dear reader, but I hate stuttery drags.

The difference between calling `[photoView setNeedsDisplay: YES]` and calling `[photoView setNeedsDisplay: myUnionOfDamagedRects]` is remarkable.