about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-08-07 14:28:28 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2021-08-10 13:19:22 +0200
commitd498e6d6971575714353f11aa4d3e63a9d2030b2 (patch)
tree804446132e86dc5afe14036eb150e0550fcb0451
parent6681694cb5914073cb2502ee442e7f48f743664f (diff)
downloadrust-d498e6d6971575714353f11aa4d3e63a9d2030b2.tar.gz
rust-d498e6d6971575714353f11aa4d3e63a9d2030b2.zip
Avoid an unnecessary allocation
-rw-r--r--src/archive.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/archive.rs b/src/archive.rs
index 47895f50780..6ba5f8e09e1 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -101,8 +101,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
         lto: bool,
         skip_objects: bool,
     ) -> io::Result<()> {
-        let obj_start = name.to_owned();
-
         self.add_archive(rlib.to_owned(), move |fname: &str| {
             // Ignore metadata files, no matter the name.
             if fname == METADATA_FILENAME {
@@ -110,13 +108,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
             }
 
             // Don't include Rust objects if LTO is enabled
-            if lto && fname.starts_with(&obj_start) && fname.ends_with(".o") {
+            if lto && fname.starts_with(name) && fname.ends_with(".o") {
                 return true;
             }
 
             // Otherwise if this is *not* a rust object and we're skipping
             // objects then skip this file
-            if skip_objects && (!fname.starts_with(&obj_start) || !fname.ends_with(".o")) {
+            if skip_objects && (!fname.starts_with(name) || !fname.ends_with(".o")) {
                 return true;
             }
 
@@ -271,7 +269,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
 impl<'a> ArArchiveBuilder<'a> {
     fn add_archive<F>(&mut self, archive_path: PathBuf, mut skip: F) -> io::Result<()>
     where
-        F: FnMut(&str) -> bool + 'static,
+        F: FnMut(&str) -> bool,
     {
         let read_cache = ReadCache::new(std::fs::File::open(&archive_path)?);
         let archive = ArchiveFile::parse(&read_cache).unwrap();