]> git.lizzy.rs Git - rust.git/commitdiff
move the reverse into the iterator
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 21 Aug 2015 18:47:02 +0000 (14:47 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 21 Aug 2015 18:47:40 +0000 (14:47 -0400)
src/librustc_data_structures/transitive_relation.rs

index 9d99f77deb9c8270f75199a6bf2979f138122f9a..728137f4ae99d11d986e6c59689d8399c26df1ac 100644 (file)
@@ -211,7 +211,7 @@ pub fn minimal_upper_bounds(&self, a: &T, b: &T) -> Vec<&T> {
             //    - In the example above, we would reverse to
             //      `[z, y, x]` and then pare down to `[z]`.
             // 4. Reverse once more just so that we yield a vector in
-            //    increasing order of index. Maybe this is silly.
+            //    increasing order of index. Not necessary, but why not.
             //
             // I believe this algorithm yields a minimal set. The
             // argument is that, after step 2, we know that no element
@@ -224,11 +224,11 @@ pub fn minimal_upper_bounds(&self, a: &T, b: &T) -> Vec<&T> {
             pare_down(&mut candidates, closure); // (2)
             candidates.reverse(); // (3a)
             pare_down(&mut candidates, closure); // (3b)
-            candidates.reverse(); // (4)
             candidates
         });
 
         lub_indices.into_iter()
+                   .rev() // (4)
                    .map(|i| &self.elements[i])
                    .collect()
     }