Skip to content
Permalink
Browse files
Ref gh-1117: Use native push for size and performance
  • Loading branch information
gibson042 committed Jan 9, 2013
1 parent 8e6c1ba commit ca49ef9
Showing 1 changed file with 2 additions and 2 deletions.
@@ -439,7 +439,7 @@ jQuery.extend({

// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
core_push.call( nodes, context.createTextNode( elem ) );
nodes.push( context.createTextNode( elem ) );

// Convert html into DOM nodes
} else {
@@ -495,7 +495,7 @@ jQuery.extend({
j = 0;
while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
core_push.call( scripts, elem );
scripts.push( elem );
}
}
}

2 comments on commit ca49ef9

@staabm
Copy link
Contributor

@staabm staabm commented on ca49ef9 Jan 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you do the same in the following lines?

core_push.apply( scripts, getAll( node, "script" ) );

core_push.apply( ret, elems );

core_push.apply( nodes, elem.nodeType ? [ elem ] : elem );

(didn't had a look into other modules, which may would benefit also from this change...)

@gibson042
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you do the same in the following lines?

core_push.apply( scripts, getAll( node, "script" ) );

core_push.apply( ret, elems );

core_push.apply( nodes, elem.nodeType ? [ elem ] : elem );

On those lines, each element of a list must be converted into an argument for push. The ones I changed are strictly single-object additions, and so don't need apply.

Please sign in to comment.