From: Tim Bunce Date: Tue, 25 Sep 2012 13:14:27 +0000 (+0900) Subject: Fix for single node. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c5078bcb5ae3022a66f7619287946ffbb7137288;p=p5sagit%2FDevel-Size.git Fix for single node. --- diff --git a/memnodes.pl b/memnodes.pl index d349ac1..a41ffec 100755 --- a/memnodes.pl +++ b/memnodes.pl @@ -168,7 +168,8 @@ while (<>) { warn "N $id d$val ends $x->{id} d$x->{depth}: size $x->{self_size}+$x->{kids_size}\n" if $opt_verbose; } - die 1 if $stack[$val]; + die "panic: stack already has item at depth $val" + if $stack[$val]; my $node = $stack[$val] = { id => $id, type => $type, name => $name, extra => $extra, attr => {}, leaves => {}, depth => $val, self_size=>0, kids_size=>0 }; enter_node($node); $seqn2node{$id} = $node; @@ -206,12 +207,11 @@ while (<>) { $dbh->commit if $dbh and $id % 10_000 == 0; } -my $x; -while (@stack > 1) { - leave_node($x = pop @stack) while @stack; - warn "EOF ends $x->{id} d$x->{depth}: size $x->{self_size}+$x->{kids_size}\n" - if $opt_verbose; -} +my $top = $stack[0]; # grab top node before we pop all the nodes +leave_node(pop @stack) while @stack; +warn "EOF ends $top->{id} d$top->{depth}: size $top->{self_size}+$top->{kids_size}\n" + if $opt_verbose; +warn Dumper($top) if $opt_verbose; if ($dot_fh) { print $dot_fh "}\n"; @@ -222,7 +222,6 @@ if ($dot_fh) { $dbh->commit if $dbh; use Data::Dumper; -warn Dumper(\$x) if $opt_verbose; warn Dumper(\%seqn2node) if %seqn2node; # should be empty =for