Color>>#hash

Andres Valloud sqrmax at cvtci.com.ar
Mon Mar 1 01:12:15 UTC 1999


Hi.

No kidding Color>>#hash is not good enough! I changed the cache's implementation
from a Dictionary to a coupled SortedCollection pair and the execution time went
down from 4m 15s to 1m 30s!!! There are two sorted collections, the first
contains associations between colors and their corresponding closest quantized
colors, and the second has just the colors. The second is looked up for the
corresponding index in the first. As the first is sorted on the key value of
associations, the indexes match. All the lookups are done using a QuickSearch
object that knows how to perform binary lookups on sorted collections. That
alone almost cut execution time by 3!!! The new tally leaves look like this:

8.3 SortedCollection class>>new:
7.5 SortedCollection(OrderedCollection)>>at:
6.4 QuickSearch>>qSearchFrom:to:
5.9 Color>>distanceTo:
5.6 BitBlt>>pixelAt:
5.3 QuickSearch>>is:leq:
4.8 Form>>setExtent:depth:
4.6 BitBlt>>pixelAt:put:
4.4 BitBlt class>>destForm:sourceForm:hal...rigin:extent:clipRect:
4.2 Rectangle class>>origin:extent:
4.1 Form class>>extent:depth:
4.1 SortedCollection(OrderedCollection)>>insert:before:
2.0 Color class>>r:g:b:range:

By the way, if you get aForm and send edit to it in a morphic world, it hangs
until you press ctrl-break, gives out a strange error and you can continue by
aborting it. And when you get up to the parent (still MVC) project, all your
aborted edits appear on the screen... ???.

Andres.





More information about the Squeak-dev mailing list