[libhtml-scrubber-perl] 03/28: Removed circular reference

Florian Schlichting fsfs at moszumanska.debian.org
Sat Nov 11 13:46:08 UTC 2017


This is an automated email from the git hooks/post-receive script.

fsfs pushed a commit to annotated tag release/0.12-TRIAL
in repository libhtml-scrubber-perl.

commit 473770549c1bd7c01c394eb9e1d1cec8b45e006d
Author: Andrei Vereha <avereha at gmail.com>
Date:   Sun Jan 11 17:48:24 2015 +0200

    Removed circular reference
    
    The delete of the circular reference at DESTROY was replaced with a weaken call.
    That way, we removed the circular reference and we  can test that there are no
    other circular refences.
---
 lib/HTML/Scrubber.pm | 6 +++---
 t/09_memory_cycle.t  | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/HTML/Scrubber.pm b/lib/HTML/Scrubber.pm
index 241732e..d7bf651 100644
--- a/lib/HTML/Scrubber.pm
+++ b/lib/HTML/Scrubber.pm
@@ -59,6 +59,8 @@ use strict;
 use warnings;
 use HTML::Parser 3.47 ();
 use HTML::Entities;
+use Scalar::Util ('weaken');
+
 our( @_scrub, @_scrub_fh );
 
 # VERSION
@@ -96,6 +98,7 @@ sub new {
     };
 
     $p->{"\0_s"} = bless $self, $package;
+    weaken($p->{"\0_s"});
 
     return $self unless @_;
 
@@ -542,9 +545,6 @@ sub _optimize {
 }
 
 
-sub DESTROY {
-    delete $_[0]->{_p}->{"\0_s"}; # break circular reference
-}
 1;
 
 #print sprintf q[ '%-12s => %s,], "$_'", $h{$_} for sort keys %h;# perl!
diff --git a/t/09_memory_cycle.t b/t/09_memory_cycle.t
new file mode 100644
index 0000000..4fe973c
--- /dev/null
+++ b/t/09_memory_cycle.t
@@ -0,0 +1,9 @@
+
+use Test::More tests => 1;
+use Test::Memory::Cycle;
+
+use HTML::Scrubber;
+
+my $scrubber = HTML::Scrubber->new();
+
+memory_cycle_ok($scrubber, "Scrubber has no cycles");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libhtml-scrubber-perl.git



More information about the Pkg-perl-cvs-commits mailing list