Henri Sivonen wrote:
Walking the DOM should be pretty fast as it only touches nodes and does not create any.
It has to create a bunch of wrappers (two per node), lots of JS functions if you're walking the DOM yourself, etc. Of course if you walk in C++ it's faster.
Unless, of course, queryInterface in XPCOM instantiates interface proxies at that point or something like that.
For some interfaces, we do use tearoffs. Stuff like nsIDOM3Node.
Presumably, the JavaScript side is actually allocating wrapper object at this point, right?
Two wrappers, since you're chrome touching content. And this is done in XPConnect, not JavaScript.
For reference, I timed Java code walking the DOM of the Web Apps 1.0 test case (without comment nodes) using the Xerces DOM
Almost irrelevant, since we have a different DOM impl, etc.
Going with strings would involve allocation overhead, whereas nsIFrame returns pointers to structs that are already there, so that might make a notable difference, assuming that the DOM walk does not actually allocate memory. But even so, the difference in wall clock time could be negligible.
Testing or profiling are the way to go, imo. As in, get it working, test, then optimize as needed.
-Boris _______________________________________________ dev-tech-layout mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-layout

