Re: [selectors api] Why two methods?

* Anne van Kesteren wrote:
>Given that the latter returns a StaticNodeList you can't do fancy stuff  
>such as lazy evaluation. So they become different in terms of speed.

Yes you can. The implementation could fetch only the first element and
wait for the script to either access another element or update the tree,
and in case of the latter expand the node list before updating the tree.
Since in case of foo(...)[0] the node list will no longer exist at that
point, there doesn't need to be a difference. It is generally also
possible to detect foo(...)[0] before executing foo() and rewrite it to
some cheaper internal method.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Saturday, 27 January 2007 23:28:26 UTC