At 7:42 PM +0100 14-03-00, Adam Wozniak wrote:
>I assume you already know not to do any expensive square roots when
>computing the distance.

Yes.

>Is multiply more expensive than test-and-branch...?
>i.e. if the difference in green values squared exceeds the minimum distance
>found so far, is there a point to doing the other two multiplications?

Probably not.  This seems like a good optimization.  It does make the worst
case worse than what we have today, but I think it improves the average
case quite a bit, and it improves the best case by maybe 60%.  I'm mildly
embarassed not to have thought of it myself.  :-)

What we should really do is find some code where WinRGBToIndex is causing
performance problems and run it through the profiler.  With the
instruction-level profiling, we can figure out exactly what's costing us.
Anyone have test code they'd be willing to donate?

>Or perhaps there are some other heurustics which can be applied.  Perhaps
>something like checking to see if the sum of the differences is below a
>certain
>value?

As it's currently implemented, it's hard to sum the distances and then go
back and sum the squares of the distances.  I think switching to try to do
this would hurt the register usage for the function enough so that it
wouldn't be a win.

                                --Bob



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to