Commits

Anonymous committed a9ed3b2

Converted $descendents to an accessor.

Comments (0)

Files changed (1)

perl/modules/XML-SemanaticDiff/lib/XML/SemanticDiff.pm

 
 use Encode qw(encode_utf8);
 
-my $descendents = {};
+foreach my $accessor (qw(descendents))
+{
+    no strict 'refs';
+    *{__PACKAGE__.'::'.$accessor} = sub {
+        my $self = shift;
+
+        if (@_)
+        {
+            $self->{$accessor} = shift;
+        }
+        return $self->{$accessor};
+    };
+}
+
 my $char_accumulator = {};
 my $doc = {};
 my $opts = {};
     my @context = $expat->context;
     my $context_length = scalar (@context);
     my $parent = $context[$context_length -1];
-    push (@{$descendents->{$parent}}, $element) if $parent;
+    push (@{$self->descendents()->{$parent}}, $element) if $parent;
 
     my $last_ctx_elem = $xml_context->[-1] || { position_index => {}};
 
     }
     
     
-    if (defined ( $descendents->{$element})) {
+    if (defined ( $self->descendents()->{$element})) {
         my $seen = {};
-        foreach my $child (@{$descendents->{$element}}) {
+        foreach my $child (@{$self->descendents()->{$element}}) {
             next if $seen->{$child};
             $seen->{$child}++;
         }
     my $self = shift;
     my $expat = shift;
     $doc = {};
-    $descendents = {};
+    $self->descendents({});
     $char_accumulator = {};
     $opts = $expat->{'Non-Expat-Options'};
     $xml_context = [];