]> git.lizzy.rs Git - rust.git/commitdiff
Avoid reallocating cgu_path_components
authorDániel Buga <bugadani@gmail.com>
Wed, 28 Oct 2020 16:05:49 +0000 (17:05 +0100)
committerDániel Buga <bugadani@gmail.com>
Wed, 28 Oct 2020 16:22:10 +0000 (17:22 +0100)
compiler/rustc_incremental/src/assert_module_sources.rs

index 80448c01a262dd3085d665ff42d6c84ebdd6f48b..17d8ac9c88297bc33ffbceab0b5c28c533e80877 100644 (file)
@@ -111,10 +111,12 @@ fn check_attr(&self, attr: &ast::Attribute) {
             (&user_path[..], None)
         };
 
-        let mut cgu_path_components = user_path.split('-').collect::<Vec<_>>();
+        let mut iter = user_path.split('-');
 
         // Remove the crate name
-        assert_eq!(cgu_path_components.remove(0), crate_name);
+        assert_eq!(iter.next().unwrap(), crate_name);
+
+        let cgu_path_components = iter.collect::<Vec<_>>();
 
         let cgu_name_builder = &mut CodegenUnitNameBuilder::new(self.tcx);
         let cgu_name =