Commit 29c52b0f authored by timmywil's avatar timmywil

Add sparse array performance improvement for inArray. Thanks rwaldron, rkatic, and jdalton

parent 76a84fba
...@@ -694,7 +694,8 @@ jQuery.extend({ ...@@ -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() { ...@@ -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;
......
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