Re: Allow to return same NodeList object for queries like getElementsByTagName, getElementsByClassName and getElementsByName

On Fri, 12 Feb 2010 14:13:57 +0100, Maciej Stachowiak <mjs@apple.com>  
wrote:
> On Feb 12, 2010, at 5:05 AM, Anne van Kesteren wrote:
>> Is it really a lot of performance? Our developers are not that  
>> convinced.
>
> A patch that made the change in WebKit was measured as a 20% speedup on  
> the Dromaeo DOM Core tests in both Safari and Chrome. Calling these  
> query methods is only a small fraction of the test, so this implies a  
> much larger speedup to the case where getElementsBy* is called in a  
> loop. Note also that this involved two different JavaScript engines so  
> it's unlikely to be a quirk specific to one engine. The Gecko bug cited  
> above also shows dramatic speedups on various tests.

It would be interesting to know what exactly that test is. Optimizing for  
benchmarks is not always useful :-)


Also, what happens with garbage collection? Say some isolated piece of  
code does:

   x = document.getElementsByTagName("x")
   x.p = 2

... and then later on some other piece of code does:

   y = document.getElementsByTagName("x")
   w("p" in y)

Depending on whether or not x got garbage collected you would get a  
different result.


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Friday, 12 February 2010 15:10:36 UTC