]> 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:46:22 +0000 (01:46 -0500)
Closes gh-1510

src/core.js

index 0dd80dd33d2e844d691d607cfb7c52ef0ed007f8..fa8436a01220af92ad24914a4af1db0a78be30f1 100644 (file)
@@ -277,25 +277,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;
                                        }
                                }
@@ -305,17 +300,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;
                                        }
                                }