mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Add sparse array performance improvement for inArray. Thanks rwaldron, rkatic, and jdalton
This commit is contained in:
parent
76a84fba94
commit
29c52b0f6c
@ -694,7 +694,8 @@ jQuery.extend({
|
|||||||
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
|
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
|
||||||
|
|
||||||
for ( ; i < len; i++ ) {
|
for ( ; i < len; i++ ) {
|
||||||
if ( array[ i ] === elem ) {
|
// Skip accessing in sparse arrays
|
||||||
|
if ( i in array && array[ i ] === elem ) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ test("attr(Hash)", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("attr(String, Object)", function() {
|
test("attr(String, Object)", function() {
|
||||||
expect(77);
|
expect(78);
|
||||||
|
|
||||||
var div = jQuery("div").attr("foo", "bar"),
|
var div = jQuery("div").attr("foo", "bar"),
|
||||||
fail = false;
|
fail = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user