diff options
author | John Resig <jeresig@gmail.com> | 2007-08-20 07:04:00 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-08-20 07:04:00 +0000 |
commit | 05fb8eaa1058578f911ab5d0d4436e97010f4cc7 (patch) | |
tree | d10051d2b45302eaff667436cca80a43928b279d /src/jquery/jquery.js | |
parent | f0353e89abf6643e5a88a649887a71a9ebd973d9 (diff) | |
download | jquery-05fb8eaa1058578f911ab5d0d4436e97010f4cc7.tar.gz jquery-05fb8eaa1058578f911ab5d0d4436e97010f4cc7.zip |
Just pushed in my changes for making jQuery.each on objects faster, sample results: http://dev.jquery.com/~john/ticket/each/obj.html
Diffstat (limited to 'src/jquery/jquery.js')
-rw-r--r-- | src/jquery/jquery.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 5ffccc5b6..76b08edf0 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1391,17 +1391,23 @@ jQuery.extend({ */ // args is for internal usage only each: function( obj, fn, args ) { - if ( obj.length == undefined ) - for ( var i in obj ) - fn.apply( obj[i], args || [i, obj[i]] ); - else if ( args ) { - for ( var i = 0, ol = obj.length; i < ol; i++ ) - if ( fn.apply( obj[i], args ) === false ) break; + if ( args ) { + if ( obj.length == undefined ) + for ( var i in obj ) + fn.apply( obj[i], args ); + else + for ( var i = 0, ol = obj.length; i < ol; i++ ) + 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] ); + } else { + if ( obj.length == undefined ) + for ( var i in obj ) + fn.call( obj[i], i, obj[i] ); + else + for ( var i = 0, ol = obj.length, val = obj[0]; + i < ol && fn.call(val,i,val) !== false; val = obj[++i] ); + } return obj; }, |