From: Dániel Buga Date: Wed, 28 Oct 2020 16:05:49 +0000 (+0100) Subject: Avoid reallocating cgu_path_components X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=2fa359814aab054f4b0c9c764a6d6a36ecf6cde8;p=rust.git Avoid reallocating cgu_path_components --- diff --git a/compiler/rustc_incremental/src/assert_module_sources.rs b/compiler/rustc_incremental/src/assert_module_sources.rs index 80448c01a26..17d8ac9c882 100644 --- a/compiler/rustc_incremental/src/assert_module_sources.rs +++ b/compiler/rustc_incremental/src/assert_module_sources.rs @@ -111,10 +111,12 @@ fn check_attr(&self, attr: &ast::Attribute) { (&user_path[..], None) }; - let mut cgu_path_components = user_path.split('-').collect::>(); + 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::>(); let cgu_name_builder = &mut CodegenUnitNameBuilder::new(self.tcx); let cgu_name =