A speedup for .remove() (which also speeds up .html()). Fixes #4178.
[jquery.git] / src / core.js
index b3142d0..c7d10f3 100644 (file)
@@ -75,7 +75,9 @@ jQuery.fn = jQuery.prototype = {
                        this.context = selector.context;
                }
 
-               return this.setArray(jQuery.makeArray(selector));
+               return this.setArray(jQuery.isArray( selector ) ?
+                       selector :
+                       jQuery.makeArray(selector));
        },
 
        // Start with an empty selector
@@ -95,7 +97,7 @@ jQuery.fn = jQuery.prototype = {
                return num === undefined ?
 
                        // Return a 'clean' array
-                       jQuery.makeArray( this ) :
+                       Array.prototype.slice.call( this ) :
 
                        // Return just the object
                        this[ num ];
@@ -265,8 +267,10 @@ jQuery.fn = jQuery.prototype = {
        },
 
        // For internal use only.
-       // Behaves like an Array's .push method, not like a jQuery method.
+       // Behaves like an Array's method, not like a jQuery method.
        push: [].push,
+       sort: [].sort,
+       splice: [].splice,
 
        find: function( selector ) {
                if ( this.length === 1 ) {
@@ -1230,7 +1234,7 @@ jQuery.each({
 
        empty: function() {
                // Remove element nodes and prevent memory leaks
-               jQuery( ">*", this ).remove();
+               jQuery(this).children().remove();
 
                // Remove any remaining nodes
                while ( this.firstChild )