Ref #14313: Optimize 1.x jQuery.merge for size.

(cherry picked from commits c75c9a8ebb f66d53c856)
This commit is contained in:
Amey Sakhadeo
2013-08-28 22:24:55 +05:30
committed by Richard Gibson
parent 5cd6868365
commit ceb5b4c9a3
2 changed files with 62 additions and 20 deletions

View File

@@ -629,15 +629,17 @@ jQuery.extend({
},
merge: function( first, second ) {
var l = second.length,
i = first.length,
j = 0;
var len = +second.length,
j = 0,
i = first.length;
if ( typeof l === "number" ) {
for ( ; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
} else {
while ( j < len ) {
first[ i++ ] = second[ j++ ];
}
// Support: IE<9
// Workaround non-numeric length overrides of otherwise arraylike objects (e.g., NodeLists)
if ( len !== len ) {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
}