Permalink
Browse files

Ref gh-1117: Use native push for size and performance

  • Loading branch information...
1 parent 8e6c1ba commit ca49ef98d51e8a79ee70d5339a662dead5711165 @gibson042 gibson042 committed Jan 9, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/manipulation.js
View
@@ -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

Contributor

staabm replied Jan 9, 2013

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...)

Member

gibson042 replied Jan 9, 2013

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.