Avoid an unnecessary allocation

This commit is contained in:
bjorn3 2021-08-07 14:28:28 +02:00
parent 6681694cb5
commit d498e6d697

View File

@ -101,8 +101,6 @@ fn add_rlib(
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 @@ fn add_rlib(
}
// 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 @@ fn inject_dll_import_lib(
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();