Opened 13 years ago
Closed 13 years ago
#6722 closed enhancement (fixed)
Fix dojo._toArray to enhance performance.
Reported by: | Tom Trenka | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | Core | Version: | 1.1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Change dojo._toArray from this:
var arr = startWith||[]; for(var x = offset || 0; x < obj.length; x++){ arr.push(obj[x]); } return arr; // Array
to this:
return (startWith||[]).concat(Array.prototype.slice.call(obj, offset||0)); // Array
(I figure this is easier than attaching a patch.)
After testing and suggestions from pottedmeat, it turns out that using Array.prototype.slice.call gives a 66% - 100% performance improvement over iterating.
I can commit this, would like a peer review. Passes the unit tests no problem.
Note: See
TracTickets for help on using
tickets.
(In [14289]) merging performance patch from Tom to speed up _toArray calculations (which many NodeList? operations spend much time in). Fixes #6722. !strict