Opened 10 years ago

Closed 7 years ago

Last modified 7 years ago

#10125 closed task (fixed)

parser and startup() refactor

Reported by: bill Owned by: bill
Priority: high Milestone: 1.7
Component: Parser Version: 1.4.0b
Keywords: Cc:
Blocked By: Blocking:

Description

The parser calls startup() on every widget that isn't parented by a _Container widget:

// Call startup on each top level instance if it makes sense (as for
// widgets).  Parent widgets will recursively call startup on their
// (non-top level) children
if(!mixin._started && !args.noStart){
	d.forEach(thelist, function(instance){
		if( instance &&
			instance.startup &&
			!instance._started &&
			(!instance.getParent || !instance.getParent())
		){
			instance.startup();
		}
	});
}

This requires a getParent() call on every widget.

Seems like a waste of CPU cycles, especially for browsers w/out querySelectorAll(). On those browsers the parser (via a call to dojo.query()) is doing a top-down traversal of the DOM tree (looking for dojoType) so it would be free to keep track of parent-child relationships.

Benchmark that change to see if it speeds up or slows down the various browsers.

See also #10061.

Change History (3)

comment:1 Changed 9 years ago by bill

Milestone: 1.52.0

Marking for 2.0 as per my comment in the code:

// TODO: for 2.0, when old instantiate() API is desupported, store parent-child
// relationships in the nodes[] array so that no getParent() call is needed.
// Note that will  require a parse() call from ContentPane setting a param that the
// ContentPane is the parent widget (so that the parse doesn't call startup() on the
// ContentPane's children)
d.forEach(thelist, function(instance){
	if(	!args.noStart && instance  && 
		instance.startup &&
		!instance._started && 
		(!instance.getParent || !instance.getParent())
	){
		instance.startup();
	}
});

comment:2 Changed 7 years ago by bill

Milestone: 2.01.7
Resolution: fixed
Status: newclosed

Actually, the getParent() call was removed in [26531].

comment:3 Changed 7 years ago by bill

In [28479]:

slight optimization, refs #10125 !strict

Note: See TracTickets for help on using tickets.