From 3aaeec97680c6839567bb4fb292d6aa1824c6031 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Fri, 18 May 2012 16:56:50 -0700 Subject: [PATCH] =?utf8?q?overload.pm:=20Don=E2=80=99t=20touch=20%OVERLOAD?= =?utf8?q?=E2=80=99s=20dummy=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Now that mro_method_changed_in (triggered by the ‘*{$package . "::()"} = \&nil;’ assignment) causes overloadedness to be checked the next time a overloaded operation occurs, it is not nec- essary to trigger %OVERLOAD’s magic explicitly. This also means that PL_amagic_generation is not incremented any more. Unfortunately, we cannot eliminate it, as there are XS modules that expect to increment it themselves to mark their caches as stale. --- ext/B/t/b.t | 11 +---------- lib/overload.pm | 2 -- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/ext/B/t/b.t b/ext/B/t/b.t index 71e0538..2534c27 100644 --- a/ext/B/t/b.t +++ b/ext/B/t/b.t @@ -277,16 +277,7 @@ is(B::opnumber("chop"), 39, "Testing opnumber with opname (chop)"); ok( $sg < B::sub_generation, "sub_generation increments" ); } -{ - my $ag = B::amagic_generation(); - { - - package Whatever; - require overload; - overload->import( '""' => sub {"What? You want more?!"} ); - } - ok( $ag < B::amagic_generation, "amagic_generation increments" ); -} +like( B::amagic_generation, qr/^\d+\z/, "amagic_generation" ); is(B::svref_2object(sub {})->ROOT->ppaddr, 'PL_ppaddr[OP_LEAVESUB]', 'OP->ppaddr'); diff --git a/lib/overload.pm b/lib/overload.pm index f270310..109b7c5 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -31,7 +31,6 @@ sub OVERLOAD { $package = shift; my %arg = @_; my ($sub, $fb); - $ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching. *{$package . "::()"} = \&nil; # Make it findable via fetchmethod. for (keys %arg) { if ($_ eq 'fallback') { @@ -62,7 +61,6 @@ sub import { sub unimport { $package = (caller())[0]; - ${$package . "::OVERLOAD"}{dummy}++; # Upgrade the table shift; for (@_) { delete $ {$package . "::"}{"(" . $_}; -- 2.7.4