logo       

Re: AutoCompMethodBrowser: msg#00229

audio.supercollider.devel

Subject: Re: AutoCompMethodBrowser

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;
> )
> > _______________________________________________
> sc-dev mailing list
> sc-dev-Ayv8T2snMLBt9CRQqspbbg@xxxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-dev
>


=====
____ James Harkins /// dewdrop world
\ / jamshark70-/E1597aS9LQAvxtiuMwx3w@xxxxxxxxxxxxxxxx
\/ http://www.dewdrop-world.net

"... love and hot pants, peace, harmony..."
-- Dick Lee, Hot Pants: The Musical


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise