http://bugzilla.spamassassin.org/show_bug.cgi?id=3841
------- Additional Comments From [EMAIL PROTECTED] 2004-09-28 17:57 ------- hmm. actually, both the before and after of that patch are less efficient than they could be. - before: is using closures (ie. "sub { $varfromoutsidescope->method($othervars) }"), which are explicitly called out as being slower than simple sub refs - after: is using eval of a string, and closures, so double-slow a better solution would be to do the following: - replace the "sub { ... }" callbacks with function references of the methods being called, e.g. "start_document => [ \&html_start ]". - set a member on the HTML::Parser object to pass "out of band" any data that needs to be passed, and then (in the callback) use that to get the Mail::SpamAssassin::HTML object $self. so e.g.: my $hp = HTML::Parser->new( api_version => 3, handlers => [ start_document => [ \&html_start, "self" ], start => [ \&html_tag, "self,tagname,attr,'+1'"], end_document => [ \&html_end, "self" ], end => [ \&html_tag, "self,tagname,attr,'-1'"], text => [ \&html_text, "self,dtext"], comment => [ \&html_comment, "self,text"], declaration => [ \&html_declaration, "self,text"], ], marked_sections => 1); $hp->{cbobject} = $self; and change those callback methods to get $self from the first argument passed into them. Would that work with ithreads? afaics it should, because they're "real" functions defined in the source, not closures. (PS: A better solution long term would be to use HTML::Parser in its subclassed form, instead of with these callbacks; that way, $self in the HTML::Parser callbacks is $self for Mail::SpamAssassin::HTML too ;) one for 3.1.0 maybe.) (PPS: I guess this means we can't switch to using Singletons for certain objects for speed, and assuming that there'd only be one Mail::SpamAssassin object per interpreter, as we were just discussing last night ;) ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee.