[cairo] [PATCH] Fix _cairo_region_get_boxes usage

Soeren Sandmann sandmann at daimi.au.dk
Tue Feb 24 05:05:28 PST 2009

Vladimir Vukicevic <vladimir at pobox.com> writes:

> On 2/15/09 4:17 PM, Chris Wilson wrote:
> > On Mon, 2009-02-16 at 01:03 +0100, Soeren Sandmann wrote:
> >> Here is a patch to do that. It's a net reduction of 56 lines, and most
> >> callers are much simpler.
> >
> > Thank you Soren, that looks a vast improvement over the current
> > get_boxes().
> I'm a little late to this party, but this replaces a quick loop with a
> function call per iteration; it probably won't matter assuming that
> the number of rectangles is low, but internally I'd rather see us
> optimize for speed even at the cost of added complexity.  If we don't,
> we risk death-by-a-thousand-cuts style performance degradation...

It's not clear to me that this actually is a performance
degradation. The old version made a copy of the array, then iterated
the copy, so it was actually two loops, and it used twice as much
cache space.

More generally, I'm not sure 'optimize for speed at the cost of
complexity' is useful as a general principle. We clearly can't
microoptimize *everything*, so the interesting question is 'is it
worth optimizing for speed in *this* case?'

I'd also argue that simplicity means less time spent tracking down
bugs, which means more time to spend on profiling, which is a much
more fruitful activity than speculative microoptimization.


More information about the cairo mailing list