Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d498e6d

Browse files
committed
Avoid an unnecessary allocation
1 parent 6681694 commit d498e6d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/archive.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,20 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
101101
lto: bool,
102102
skip_objects: bool,
103103
) -> io::Result<()> {
104-
let obj_start = name.to_owned();
105-
106104
self.add_archive(rlib.to_owned(), move |fname: &str| {
107105
// Ignore metadata files, no matter the name.
108106
if fname == METADATA_FILENAME {
109107
return true;
110108
}
111109

112110
// Don't include Rust objects if LTO is enabled
113-
if lto && fname.starts_with(&obj_start) && fname.ends_with(".o") {
111+
if lto && fname.starts_with(name) && fname.ends_with(".o") {
114112
return true;
115113
}
116114

117115
// Otherwise if this is *not* a rust object and we're skipping
118116
// objects then skip this file
119-
if skip_objects && (!fname.starts_with(&obj_start) || !fname.ends_with(".o")) {
117+
if skip_objects && (!fname.starts_with(name) || !fname.ends_with(".o")) {
120118
return true;
121119
}
122120

@@ -271,7 +269,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
271269
impl<'a> ArArchiveBuilder<'a> {
272270
fn add_archive<F>(&mut self, archive_path: PathBuf, mut skip: F) -> io::Result<()>
273271
where
274-
F: FnMut(&str) -> bool + 'static,
272+
F: FnMut(&str) -> bool,
275273
{
276274
let read_cache = ReadCache::new(std::fs::File::open(&archive_path)?);
277275
let archive = ArchiveFile::parse(&read_cache).unwrap();

0 commit comments

Comments
 (0)