Skip to content

Commit cef60e1

Browse files
committed
Fix outline node construction.
1 parent ed593a9 commit cef60e1

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

lib/PDF/Class/OutlineNode.rakumod

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ unit role PDF::Class::OutlineNode;
22

33
use PDF::COS;
44
use PDF::Destination :coerce-dest, :DestinationLike, :DestRef;
5-
has Array $.parents is rw;
65
sub siblings($first) is rw {
76
my class Siblings does Iterable {
87
has $.first is required;
@@ -27,26 +26,21 @@ method add-kid(Hash $kid is copy = {}) {
2726
}
2827
$kid = (require PDF::Outline).COERCE: $kid;
2928
$kid.Dest = $_ with $dest;
30-
$kid.parents //= [];
31-
$kid.parents.push: self;
29+
$kid.Parent = self;
3230
with self.Last {
3331
.Next = $kid;
3432
$kid.Prev = $_;
3533
}
3634
self.Last = $kid;
3735
self.First //= $kid;
3836
my %seen{Any};
39-
my @nodes = $kid;
37+
my $node = $kid;
4038

41-
while @nodes {
42-
my $node = @nodes.shift;
43-
unless %seen{$node}++ {
44-
$node.Count++;
45-
with $node.parents {
46-
@nodes.push: $_
47-
for .list;
48-
}
49-
}
39+
while $node {
40+
last if %seen{$node}++;
41+
$node.Count++;
42+
last unless $node.can('Parent');
43+
$node .= Parent;
5044
}
5145
$kid.kids = $_ with $grand-kids;
5246
$kid;

0 commit comments

Comments
 (0)