[Jifty-commit] r5657 - B-OPCheck/lib/B
Jifty commits
jifty-commit at lists.jifty.org
Sun Aug 3 20:52:49 EDT 2008
Author: nothingmuch
Date: Sun Aug 3 20:52:48 2008
New Revision: 5657
Modified:
B-OPCheck/lib/B/OPCheck.pm
Log:
allow unimporting of a certain hook, and in general try to be cleaner about how leavescope is called, esp. on multiple use B::OPCheck imports per scope
Modified: B-OPCheck/lib/B/OPCheck.pm
==============================================================================
--- B-OPCheck/lib/B/OPCheck.pm (original)
+++ B-OPCheck/lib/B/OPCheck.pm Sun Aug 3 20:52:48 2008
@@ -19,18 +19,25 @@
$^H |= 0x120000; # set HINT_LOCALIZE_HH + an unused bit to work around a %^H bug
- my $leave_scope = sub {
- leavescope();
- };
-
- my $sg = Scope::Guard->new($leave_scope);
- $^H{OPCHECK_leavescope} = $sg;
+ my $by_opname = $^H{OPCHECK_leavescope} ||= {};
+ my $guards = $by_opname->{$opname} ||= [];
+ push @$guards, Scope::Guard->new(sub {
+ leavescope($opname, $sub);
+ });
enterscope($opname, $sub );
}
sub unimport {
- my ($class) = @_;
+ my ($class, $opname) = @_;
+
+ if ( defined $opname ) {
+ my $by_opname = $^H{OPCHECK_leavescope};
+ delete $by_opname->{$opname};
+ return if scalar keys %$by_opname; # don't delete other things
+ }
+
+ delete $^H{OPCHECK_leavescope};
$^H &= ~0x120000;
}
More information about the Jifty-commit
mailing list