in reply to Class::InsideOut doesn't play nicely with DProf

You should be able to replace the use of goto in the four subroutines private(), property(), public() & readonly() with a normal function call if you postpend the caller() to @_, and the only difference will be that it will run (marginally) faster. That is, property() would become:

sub property($\%;$) { ## no critic -- prototype &_check_property; push @_, scalar caller(); &_install_property; }

and _install_property() would become:

sub _install_property{ my ($label, $hash, $opt, $caller) = @_; # my $caller = caller(0); # we get here via "goto", so caller(0) is + right $PROP_DATA_FOR{ $caller }{$label} = $hash; my $options = _merge_options( $caller, $opt ); if ( exists $options->{privacy} && $options->{privacy} eq 'public' + ) { no strict 'refs'; *{ "$caller\::$label" } = ($options->{set_hook} || $options->{get_hook}) ? _gen_hook_accessor( $hash, $label, $options->{get_ho +ok}, $options->{set_hook} +) : _gen_accessor( $hash ) ; $PUBLIC_PROPS_FOR{ $caller }{ $label } = 1; } return; }

That's untested, but I believe it shoudl work and be a little quicker. That only leaves the goto at line 81 (There is no goto at line: 666? Maybe the "evil" connotations made you miss that the line number 666 related to dprof_pp rather than the source file :).

This might be more awkward as Exporter might rely upon caller() being different, though I've never seen anyone else that subclasses Exporter use goto. I think you should try just deleting the goto on line 81 and see what happens.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Class::InsideOut doesn't play nicely with DProf
by patspam (Sexton) on Jul 01, 2008 at 11:52 UTC
    Sadly no good - the suggested changes make modules using Class::InsideOut go boom. Sorry about the incorrect line number, the goto I'm really interested in nuking is the one at line 79:
    goto &Exporter::import;

      I've looked into it. Please try replacing that line with these:

      local $Exporter::ExportLevel = $Exporter::ExportLevel + 1; &Exporter::import;

      I don't really like playing with a global hack like that, but it's limited in scope and Class::InsideOut still passes all its tests.

      Let me know if that works for you with DProf and if it does, I'll release it as Class::InsideOut 1.10


      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.