Fix is committed, along with a couple of minor changes I'd been
thinking of for awhile.
hjh
On Wednesday, Aug 25, 2004, at 21:20 US/Eastern, James Harkins wrote:
OK, I'll change it tonight. I didn't know about the
impact on GC when I wrote it.
hjh
--- James McCartney <asynth-Xhj3G7Rj6JI@xxxxxxxxxxxxxxxx> wrote:
classvar methDict; // note, not the same as
Class-methods
// this is a dictionary: selector ->
[method,
method, method...]
// with this, I can look up method
selectors
almost instantly
// otherwise, every time I would have to
search
the whole class
tree (slow)
*initClass {
methDict = IdentityDictionary.new;
Class.allClasses.do({ |class|
class.methods.do({ |meth|
// if this selector hasn't been
initialized,
make a new set
methDict[meth.name].isNil.if({
methDict.put(meth.name, Set.new); });
methDict[meth.name].add(meth);
});
});
methodExclusions = [];
}
This is really wasteful. It creates a huge
directory, most of which is
never used. It should be done as needed.
To do it each time it is needed is not so slow.
The
code below runs in
40 milliseconds on my machine.
Perhaps a primitive that returns the methods for a
selector would help
here if speed is really a problem.
Why is the Set not an IdentitySet?
All those objects make the GC take longer to
complete a cycle resulting
in more garbage generated before a collection.
Larger working sets also
make cache performance worse.
(
var methods, selector;
selector = \value;
bench {
methods = [];
Class.allClasses.do({ |class|
class.methods.do({ |meth|
if (meth.name == selector) {
methods = methods.add(meth);
}
});
});
};
methods.postln;
)
____________________________________
H. James Harkins /// dewdrop_world
http://www.dewdrop-world.net
"If attacked by a lion, thrust your arm down his throat.
This takes some practice." -- Cyril Connolly