Just pushed in my changes for making jQuery.each on objects faster, sample results: http://dev.jquery.com/~john/ticket/each/obj.html
This commit is contained in:
parent
f0353e89ab
commit
05fb8eaa10
12
src/jquery/jquery.js
vendored
12
src/jquery/jquery.js
vendored
|
@ -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 ( args ) {
|
||||||
if ( obj.length == undefined )
|
if ( obj.length == undefined )
|
||||||
for ( var i in obj )
|
for ( var i in obj )
|
||||||
fn.apply( obj[i], args || [i, obj[i]] );
|
fn.apply( obj[i], args );
|
||||||
else if ( args ) {
|
else
|
||||||
for ( var i = 0, ol = obj.length; i < ol; i++ )
|
for ( var i = 0, ol = obj.length; i < ol; i++ )
|
||||||
if ( fn.apply( obj[i], args ) === false ) break;
|
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 {
|
||||||
|
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];
|
for ( var i = 0, ol = obj.length, val = obj[0];
|
||||||
i < ol && fn.call(val,i,val) !== false; val = obj[++i] );
|
i < ol && fn.call(val,i,val) !== false; val = obj[++i] );
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue