]> source.dussan.org Git - jquery.git/commitdiff
Core: Simplify and speed up .each
authorDaniel Husar <dano.husar@gmail.com>
Fri, 7 Feb 2014 10:30:13 +0000 (10:30 +0000)
committerRichard Gibson <richard.gibson@gmail.com>
Tue, 9 Dec 2014 06:47:40 +0000 (01:47 -0500)
Closes gh-1510

(cherry picked from commit eeda11cdd6a69ec2ef4e9c1ed12b82a79910fda5)

src/core.js

index 5251dc63994689dd476f8b62e86b1ac241448bd2..3a693b4f543f178228a9b93c8991daaf92493061 100644 (file)
@@ -301,25 +301,20 @@ jQuery.extend({
 
        // args is for internal usage only
        each: function( obj, callback, args ) {
-               var value,
-                       i = 0,
+               var i = 0,
                        length = obj.length,
                        isArray = isArraylike( obj );
 
                if ( args ) {
                        if ( isArray ) {
                                for ( ; i < length; i++ ) {
-                                       value = callback.apply( obj[ i ], args );
-
-                                       if ( value === false ) {
+                                       if ( callback.apply( obj[ i ], args ) === false ) {
                                                break;
                                        }
                                }
                        } else {
                                for ( i in obj ) {
-                                       value = callback.apply( obj[ i ], args );
-
-                                       if ( value === false ) {
+                                       if ( callback.apply( obj[ i ], args ) === false ) {
                                                break;
                                        }
                                }
@@ -329,17 +324,13 @@ jQuery.extend({
                } else {
                        if ( isArray ) {
                                for ( ; i < length; i++ ) {
-                                       value = callback.call( obj[ i ], i, obj[ i ] );
-
-                                       if ( value === false ) {
+                                       if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
                                                break;
                                        }
                                }
                        } else {
                                for ( i in obj ) {
-                                       value = callback.call( obj[ i ], i, obj[ i ] );
-
-                                       if ( value === false ) {
+                                       if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
                                                break;
                                        }
                                }