]> source.dussan.org Git - jquery.git/commitdiff
Avoid running jQuery.unique() for methods that are guaranteed to produce a unique... 180/head
authorScott González <scott.gonzalez@gmail.com>
Fri, 14 Jan 2011 14:55:40 +0000 (09:55 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 14 Jan 2011 14:55:40 +0000 (09:55 -0500)
src/traversing.js

index 689e90196ab27905b726a9a708390d374601829d..e169be084231373ead81607f15ab2ba33f6ba4d5 100644 (file)
@@ -6,7 +6,14 @@ var runtil = /Until$/,
        rmultiselector = /,/,
        isSimple = /^.[^:#\[\.,]*$/,
        slice = Array.prototype.slice,
-       POS = jQuery.expr.match.POS;
+       POS = jQuery.expr.match.POS,
+       // methods guaranteed to produce a unique set when starting from a unique set
+       guaranteedUnique = {
+               children: true,
+               contents: true,
+               next: true,
+               prev: true
+       };
 
 jQuery.fn.extend({
        find: function( selector ) {
@@ -206,7 +213,7 @@ jQuery.each({
                        ret = jQuery.filter( selector, ret );
                }
 
-               ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+               ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
 
                if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
                        ret = ret.reverse();