Skip to content
Permalink
Browse files

Optimization of array operations, closes gh-844.

  • Loading branch information
markelog authored and dmethvin committed Jun 28, 2012
1 parent f8baea8 commit 05aff402310d7db5d15f96b15071af6aa21a2afc
Showing with 12 additions and 16 deletions.
  1. +2 −8 src/core.js
  2. +9 −7 src/manipulation.js
  3. +1 −1 src/traversing.js
@@ -197,15 +197,9 @@ jQuery.fn = jQuery.prototype = {
// Take an array of elements and push it onto the stack
// (returning the new matched element set)
pushStack: function( elems, name, selector ) {
// Build a new jQuery matched element set
var ret = this.constructor();

if ( jQuery.isArray( elems ) ) {
core_push.apply( ret, elems );

} else {
jQuery.merge( ret, elems );
}
// Build a new jQuery matched element set
var ret = jQuery.merge( this.constructor(), elems );

// Add the old object onto the stack (as a reference)
ret.prevObject = this;
@@ -146,10 +146,11 @@ jQuery.fn.extend({
return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this );
});
} else if ( arguments.length ) {
}

if ( arguments.length ) {
var set = jQuery.clean( arguments );
set.push.apply( set, this.toArray() );
return this.pushStack( set, "before", arguments );
return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
}
},

@@ -158,10 +159,11 @@ jQuery.fn.extend({
return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this.nextSibling );
});
} else if ( arguments.length ) {
var set = this.pushStack( this, "after", arguments );
set.push.apply( set, jQuery.clean(arguments) );
return set;
}

if ( arguments.length ) {
var set = jQuery.clean( arguments );
return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
}
},

@@ -199,7 +199,7 @@ jQuery.each({
contents: function( elem ) {
return jQuery.nodeName( elem, "iframe" ) ?
elem.contentDocument || elem.contentWindow.document :
jQuery.makeArray( elem.childNodes );
jQuery.merge( [], elem.childNodes );
}
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {

0 comments on commit 05aff40

Please sign in to comment.
You can’t perform that action at this time.