Ticket #6722 (new enhancement)
Opened 6 days ago
Fix dojo._toArray to enhance performance.
| Reported by: | ttrenka | Owned by: | alex |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.2 |
| Component: | Core | Version: | 1.1.0 |
| Severity: | normal | Keywords: | |
| Cc: |
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.