W3C home > Mailing lists > Public > public-webapi@w3.org > January 2007

Re: [selectors api] Why two methods?

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Sun, 28 Jan 2007 00:28:18 +0100
To: "Anne van Kesteren" <annevk@opera.com>
Cc: public-webapi@w3.org
Message-ID: <hhnnr2lbluvk3og54dd8n8tfpmv5v6v14t@hive.bjoern.hoehrmann.de>

* 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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:22 UTC