]> source.dussan.org Git - jquery.git/commitdiff
Optimization of array operations, closes gh-844.
authorOleg <markelog@gmail.com>
Thu, 28 Jun 2012 00:55:36 +0000 (04:55 +0400)
committerDave Methvin <dave.methvin@gmail.com>
Fri, 6 Jul 2012 13:48:52 +0000 (09:48 -0400)
src/core.js
src/manipulation.js
src/traversing.js

index 9a506f31e23f83369ce12e0a9c0fd90d1ed52824..c92774075d6806ed58ab4212d011ad6948bb81f5 100644 (file)
@@ -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;
index 9ca6b0a17ca63bce4bf26191dbd03de6b3f2e5ae..fafccffbbbea3ccb5f86efc6d8bed673fd96d28f 100644 (file)
@@ -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 );
                }
        },
 
index 4a68ccb5e31706e9d67a71ac3d2a5cfdde53c18e..a3b2be213150844073836c7f142de10c1a8237a6 100644 (file)
@@ -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 ) {