Skip Menu |

This queue is for tickets about the XML-Twig CPAN distribution.

Report information
The Basics
Id: 54570
Status: resolved
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: andrew [...] pimlott.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: after $elt->cut_children, $elt->empty is false
Date: Fri, 12 Feb 2010 12:38:55 -0800
To: bug-XML-Twig [...] rt.cpan.org
From: Andrew Pimlott <andrew [...] pimlott.net>
Verified on Twig.pm 3.35. I'll cite the code in Twig_pm.slow. $elt->cut_children calls $elt->cut on every element. When called on the last element, the test at line 6410 is true: if( $parent->_last_child == $elt) { $parent->set_last_child( $elt->_prev_sibling); } $elt->_prev_sibling is of course undef at this point, but set_last_child still assumes that calling it makes the element not empty: sub set_last_child { $_[0]->set_not_empty; On line 6408, there is a "fix-up" to set the element back to empty when set_first_child was called with an undef value. The same thing could be done for set_last_child. I note, by the way, that your speedup script transforms the call to set_first_child differently from the call to set_last_child. That is curious to me, though I didn't look into why. Andrew --- Twig_pm.slow.orig 2010-02-12 20:35:30.000000000 +0000 +++ Twig_pm.slow 2010-02-12 20:34:04.000000000 +0000 @@ -6407,7 +6407,10 @@ { $parent->set_first_child( $elt->_next_sibling); unless( $elt->_next_sibling) { $parent->set_empty; } } - if( $parent->_last_child == $elt) { $parent->set_last_child( $elt->_prev_sibling); } + if( $parent->_last_child == $elt) + { $parent->set_last_child( $elt->_prev_sibling); + unless( $elt->{prev_sibling}) { $parent->{empty}= 1; } + } if( $prev_sibling= $elt->_prev_sibling) { $prev_sibling->set_next_sibling( $elt->_next_sibling); }
Subject: Re: [rt.cpan.org #54570] after $elt->cut_children, $elt->empty is false
Date: Tue, 16 Feb 2010 10:19:28 +0100
To: bug-XML-Twig [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
andrew@pimlott.net via RT wrote: Show quoted text
> Fri Feb 12 15:40:40 2010: Request 54570 was acted upon. > Transaction: Ticket created by andrew@pimlott.net > Queue: XML-Twig > Subject: after $elt->cut_children, $elt->empty is false > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: andrew@pimlott.net > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=54570 > > > > Verified on Twig.pm 3.35. I'll cite the code in Twig_pm.slow. > > $elt->cut_children calls $elt->cut on every element. When called on the > last element, the test at line 6410 is true: > > if( $parent->_last_child == $elt) { $parent->set_last_child( $elt->_prev_sibling); } > > $elt->_prev_sibling is of course undef at this point, but set_last_child > still assumes that calling it makes the element not empty: > > sub set_last_child > { $_[0]->set_not_empty; > > On line 6408, there is a "fix-up" to set the element back to empty when > set_first_child was called with an undef value. The same thing could be > done for set_last_child.
OK, the patch looks good. It causes a bunch of tests to fail though, and at least one of them seems to show an other possible bug. I have to investigate a little further. Show quoted text
> I note, by the way, that your speedup script transforms the call to > set_first_child differently from the call to set_last_child. That is > curious to me, though I didn't look into why.
That's because the links are slightly different, the link from the parent to the last_child is weaken'ed. Thanks for the report and patch. -- mirod