I think I have just found a way to really optimize Element.Down().
At the moment if you pass in any arguments (expression or index) the
runtime seems to be proportional to the number of descendants, order
N. However, because we are only looking down the tree we can use
getElementBySelector, which seems to be virtually independant of the
number of descendants.
Also I find most of the time my developers are using it with just a
single tagName eg element.down(''li'', 2), if we add a line to
Selector.findChildElements which checks for this (see below) and uses
getElementsByTagName, I gained another 20% in speed!
if (expressions.length === 1 && expressions[0].match(/^[a-z]*$/))
return
$A(element.getElementsByTagName(expressions[0])).collect(Element.extend);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---