Commit 05fb8eaa authored by John Resig's avatar John Resig

Just pushed in my changes for making jQuery.each on objects faster, sample...

Just pushed in my changes for making jQuery.each on objects faster, sample results: http://dev.jquery.com/~john/ticket/each/obj.html
parent f0353e89
...@@ -1391,17 +1391,23 @@ jQuery.extend({ ...@@ -1391,17 +1391,23 @@ jQuery.extend({
*/ */
// args is for internal usage only // args is for internal usage only
each: function( obj, fn, args ) { each: function( obj, fn, args ) {
if ( obj.length == undefined ) if ( args ) {
for ( var i in obj ) if ( obj.length == undefined )
fn.apply( obj[i], args || [i, obj[i]] ); for ( var i in obj )
else if ( args ) { fn.apply( obj[i], args );
for ( var i = 0, ol = obj.length; i < ol; i++ ) else
if ( fn.apply( obj[i], args ) === false ) break; 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 // A special, fast, case for the most common use of each
} else } else {
for ( var i = 0, ol = obj.length, val = obj[0]; if ( obj.length == undefined )
i < ol && fn.call(val,i,val) !== false; val = obj[++i] ); 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; return obj;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment