Ticket #2648 (closed defect: wontfix)

Opened 16 months ago

Last modified 4 months ago

toCamelCase is slow on IE6

Reported by: guest Owned by: anonymous
Priority: normal Milestone:
Component: General Version: 0.4.2
Severity: normal Keywords:
Cc:

Description

(from sdrye at atg.com, ATG CLA on file)

The toCamelCase function is slow on IE6, and can be improved for the other browsers, too.

Using Tito Web Studio to profile laying out our UI onresize, I noticed that toCamelCase was using 20+% of the time on IE6 (~7% on Firefox 2). Adding a simple cache to the function drastically sped it up, so it was only taking 7% of the time on IE6 (~2% on Firefox).

I think adding this cache is a good idea, since the set of selectors is not that large. It could even be pre-populated, but that would increase the download size so it might not be worth it.

Here's my patch (not in diff form, since it's pretty trivial):

dojo.html.toCamelCaseMap = {};
dojo.html.toCamelCase = function(/* string */selector){
	//	summary
	//	Translates a CSS selector string to a camel-cased one.
    if (dojo.html.toCamelCaseMap[selector]) return dojo.html.toCamelCaseMap[selector];
	var arr = selector.split('-'), cc = arr[0];
	for(var i = 1; i < arr.length; i++) {
		cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1);
	}
	dojo.html.toCamelCaseMap[selector] = cc;
	return cc;	//	string
}

Change History

Changed 16 months ago by jburke

  • milestone set to 0.4.3

Setting to 0.4.3, but feel free to override. I tried it out for one the apps I work on, and saw a 10% improvement during widget creation and init/resizing phase. Patch needs to be reworked for Dojo style, but seemed to be useful.

Changed 12 months ago by peller

  • status changed from new to closed
  • resolution set to wontfix

We did away with toCamelCase for 0.9

Changed 4 months ago by anonymous

  • milestone deleted

Milestone 0.4.4 deleted

Note: See TracTickets for help on using tickets.