diff options
author | John Resig <jeresig@gmail.com> | 2007-03-24 21:55:03 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-03-24 21:55:03 +0000 |
commit | ec2b688920cf38f5bb2487b8a1897f7eb7557248 (patch) | |
tree | 2e37bf471217f3ce20d7799e5f239278e89afc69 /src/jquery/jquery.js | |
parent | 1b9f4d3d2e1bc2dfd7572da77159fa01f9ab5d6e (diff) | |
download | jquery-ec2b688920cf38f5bb2487b8a1897f7eb7557248.tar.gz jquery-ec2b688920cf38f5bb2487b8a1897f7eb7557248.zip |
Merged my speed improvements into the jQuery core (is actually 200b smaller now!). Additionally, added in some better reporting to the test suite, and fixed a bug with how selector tests were performmed.
Diffstat (limited to 'src/jquery/jquery.js')
-rw-r--r-- | src/jquery/jquery.js | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 489522f63..a8872dfb8 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -817,9 +817,9 @@ jQuery.fn = jQuery.prototype = { * @cat DOM/Traversing */ find: function(t) { - return this.pushStack( jQuery.map( this, function(a){ + return this.pushStack( jQuery.unique( jQuery.map( this, function(a){ return jQuery.find(t,a); - }), t ); + }) ), t ); }, /** @@ -1629,19 +1629,26 @@ jQuery.extend({ * @cat JavaScript */ merge: function(first, second) { - var r = [].slice.call( first, 0 ); - - // Now check for duplicates between the two arrays - // and only add the unique items for ( var i = 0, sl = second.length; i < sl; i++ ) - // Check for duplicates - if ( jQuery.inArray( second[i], r ) == -1 ) - // The item is unique, add it - first.push( second[i] ); + first.push(second[i]); return first; }, + unique: function(first) { + var r = [], num = jQuery.mergeNum++; + + for ( var i = 0, fl = first.length; i < fl; i++ ) + if ( first[i].mergeNum != num ) { + first[i].mergeNum = num; + r.push(first[i]); + } + + return r; + }, + + mergeNum: 0, + /** * Filter items out of an array, by using a filter function. * @@ -1735,17 +1742,7 @@ jQuery.extend({ } } - var r = result.length ? [ result[0] ] : []; - - check: for ( var i = 1, rl = result.length; i < rl; i++ ) { - for ( var j = 0; j < i; j++ ) - if ( result[i] == r[j] ) - continue check; - - r.push( result[i] ); - } - - return r; + return result; } }); |