Just pushed some major speed improvements through for $.each() - we're now seeing...
[jquery.git] / src / jquery / jquery.js
index b7091e2..5ffccc5 100644 (file)
@@ -1160,6 +1160,10 @@ jQuery.fn = jQuery.prototype = {
                        ( this.length ? this[0].innerHTML : null ) :
                        this.empty().append( val );
        },
+
+       slice: function() {
+               return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
+       },
        
        /**
         * @private
@@ -1390,9 +1394,15 @@ jQuery.extend({
                if ( obj.length == undefined )
                        for ( var i in obj )
                                fn.apply( obj[i], args || [i, obj[i]] );
-               else
+               else if ( args ) {
                        for ( var i = 0, ol = obj.length; i < ol; i++ )
-                               if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
+                               if ( fn.apply( obj[i], args ) === false ) break;
+
+               // A special, fast, case for the most common use of each
+               } else
+                       for ( var i = 0, ol = obj.length, val = obj[0]; 
+                               i < ol && fn.call(val,i,val) !== false; val = obj[++i] );
+
                return obj;
        },