]> git.lizzy.rs Git - rust.git/commitdiff
Avoid an excessive use of iterator chain
authorSeo Sanghyeon <sanxiyn@gmail.com>
Mon, 2 Feb 2015 09:33:24 +0000 (18:33 +0900)
committerSeo Sanghyeon <sanxiyn@gmail.com>
Mon, 2 Feb 2015 09:33:24 +0000 (18:33 +0900)
src/librustdoc/clean/mod.rs

index fe502922ffdf280b7ddd08f284e82b19b1373349..d5c0387943874b7537e16b776c2346658fdfc18f 100644 (file)
@@ -355,21 +355,21 @@ fn clean(&self, cx: &DocContext) -> Item {
         } else {
             "".to_string()
         };
-        let items: Vec<Item> =
-                   self.extern_crates.iter().map(|x| x.clean(cx))
-            .chain(self.imports.iter().flat_map(|x| x.clean(cx).into_iter()))
-            .chain(self.structs.iter().map(|x| x.clean(cx)))
-            .chain(self.enums.iter().map(|x| x.clean(cx)))
-            .chain(self.fns.iter().map(|x| x.clean(cx)))
-            .chain(self.foreigns.iter().flat_map(|x| x.clean(cx).into_iter()))
-            .chain(self.mods.iter().map(|x| x.clean(cx)))
-            .chain(self.typedefs.iter().map(|x| x.clean(cx)))
-            .chain(self.statics.iter().map(|x| x.clean(cx)))
-            .chain(self.constants.iter().map(|x| x.clean(cx)))
-            .chain(self.traits.iter().map(|x| x.clean(cx)))
-            .chain(self.impls.iter().map(|x| x.clean(cx)))
-            .chain(self.macros.iter().map(|x| x.clean(cx)))
-            .collect();
+
+        let mut items: Vec<Item> = vec![];
+        items.extend(self.extern_crates.iter().map(|x| x.clean(cx)));
+        items.extend(self.imports.iter().flat_map(|x| x.clean(cx).into_iter()));
+        items.extend(self.structs.iter().map(|x| x.clean(cx)));
+        items.extend(self.enums.iter().map(|x| x.clean(cx)));
+        items.extend(self.fns.iter().map(|x| x.clean(cx)));
+        items.extend(self.foreigns.iter().flat_map(|x| x.clean(cx).into_iter()));
+        items.extend(self.mods.iter().map(|x| x.clean(cx)));
+        items.extend(self.typedefs.iter().map(|x| x.clean(cx)));
+        items.extend(self.statics.iter().map(|x| x.clean(cx)));
+        items.extend(self.constants.iter().map(|x| x.clean(cx)));
+        items.extend(self.traits.iter().map(|x| x.clean(cx)));
+        items.extend(self.impls.iter().map(|x| x.clean(cx)));
+        items.extend(self.macros.iter().map(|x| x.clean(cx)));
 
         // determine if we should display the inner contents or
         // the outer `mod` item for the source code.