Skip to content
Permalink
Browse files

Add sparse array performance improvement for inArray. Thanks rwaldron…

…, rkatic, and jdalton
  • Loading branch information...
timmywil committed Sep 15, 2011
1 parent 76a84fb commit 29c52b0f6caa23403fd2942aa292b84ce1278191
Showing with 3 additions and 2 deletions.
  1. +2 −1 src/core.js
  2. +1 −1 test/unit/attributes.js
@@ -694,7 +694,8 @@ jQuery.extend({
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;

for ( ; i < len; i++ ) {
if ( array[ i ] === elem ) {
// Skip accessing in sparse arrays
if ( i in array && array[ i ] === elem ) {
return i;
}
}
@@ -156,7 +156,7 @@ test("attr(Hash)", function() {
});

test("attr(String, Object)", function() {
expect(77);
expect(78);

var div = jQuery("div").attr("foo", "bar"),
fail = false;

0 comments on commit 29c52b0

Please sign in to comment.
You can’t perform that action at this time.