overload.pm: Don’t touch %OVERLOAD’s dummy entry
authorFather Chrysostomos <sprout@cpan.org>
Fri, 18 May 2012 23:56:50 +0000 (16:56 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 22 May 2012 01:09:30 +0000 (18:09 -0700)
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
lib/overload.pm

index 71e0538..2534c27 100644 (file)
@@ -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');
index f270310..109b7c5 100644 (file)
@@ -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 . "::"}{"(" . $_};