--- In [email protected], "polestar11" <[EMAIL PROTECTED]> 
wrote:
>
> ... just discovered how terribly unoptimized code can be.
> 
> Changed the delete code snippet from the below example to the 
following:
> delete body.children()[count]; // takes 53636ms
>  
> and then the following:
> delete spans[count]; // takes 852ms
> 
> Obviously constructing a child array each time in the loop on a 
large
> list of children is hugely inefficient. 
> 
> 
> 
> --- In [email protected], "polestar11" <polestar11@> wrote:
> >
> > Hi there
> > 
> > I'm busy crunching through xml data, stripping out nodes that 
don't
> > have children. Perhaps its not the best way to do things, but I 
use a
> > for loop that checks and deletes any item with no children. I've
> > always found XML delete tricky and to do this I reference the 
parent
> > which finds the child index and deletes the child.
> > On a file of 10000+ items execution time is 600ms without the 
delete.
> > With the delete execution time is 52919ms!
> > 
> > I'm off to find another delete function ...
> > 
> > for each(span in body.span) {
> >     if(span.children().length() == 0) {
> >             delete span.parent().children()[span.childIndex()];
> >     }
> >     else {
> >             [EMAIL PROTECTED] = SPAN_PREFIX + id++;
> >             [EMAIL PROTECTED] = "itemClicked('"[EMAIL PROTECTED]"', 
AIR.itemSelected)";
> >             [EMAIL PROTECTED] = span.attribute("class");
> >     }
> > }
> >

How fast is it if you use body.span.normalize() or body.normalize()?


Reply via email to