Permalink
Browse files

Core: Simplify and speed up .each

Closes gh-1510

(cherry picked from commit eeda11c)
  • Loading branch information...
danielhusar authored and gibson042 committed Feb 7, 2014
1 parent aec41a5 commit 4cc4e54298bca84d0a0b2f2eb1ee97ca619485b1
Showing with 5 additions and 14 deletions.
  1. +5 −14 src/core.js
View
@@ -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;
}
}

0 comments on commit 4cc4e54

Please sign in to comment.