Saturday, May 07, 2005

First draft finished

Oh yeah! My reference finder based on Laws of Form is working!

My previous approach had just a few ifTrue:/ifFalse: in it, and was relatively fast for what it was doing. But the form/distinction approach takes less than half the time!

I haven't even tried to make it go fast yet. What I learned in the previous version is that one of the issues is instance creation --- the form/distinction scanning model relies heavily on it. If it is also an issue with this version, a discarded/free list of forms should help curb that.

As you traverse the object graph, you need to avoid scanning the same object twice because otherwise you're doing extra work. In other words:

Calling a name twice is the same as calling a name once

That's one of the axioms of Laws of Form! Argh! This stuff is everywhere!

So the typical approach is to keep all the objects you visited in some sort of identity set. The issue though is that you typically need to send two messages to it per object you visit. The first one is #includes: (to see if you called a name once already), and the other one is #add: (to remember a name you just used).

But if you look at how that is implemented, you'll see the collection is doing the same work twice! I had enough of that and implemented #ifExcludedAdd:. The collection will answer whether it added the object or not, which is the two pieces of work I need for the price of one.

I wonder what other things the profiler will tell me now. But first, time to package & publish to StORE...

No comments: