Avoid an unnecessary allocation
This commit is contained in:
parent
6681694cb5
commit
d498e6d697
@ -101,8 +101,6 @@ fn add_rlib(
|
|||||||
lto: bool,
|
lto: bool,
|
||||||
skip_objects: bool,
|
skip_objects: bool,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
let obj_start = name.to_owned();
|
|
||||||
|
|
||||||
self.add_archive(rlib.to_owned(), move |fname: &str| {
|
self.add_archive(rlib.to_owned(), move |fname: &str| {
|
||||||
// Ignore metadata files, no matter the name.
|
// Ignore metadata files, no matter the name.
|
||||||
if fname == METADATA_FILENAME {
|
if fname == METADATA_FILENAME {
|
||||||
@ -110,13 +108,13 @@ fn add_rlib(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Don't include Rust objects if LTO is enabled
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise if this is *not* a rust object and we're skipping
|
// Otherwise if this is *not* a rust object and we're skipping
|
||||||
// objects then skip this file
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +269,7 @@ fn inject_dll_import_lib(
|
|||||||
impl<'a> ArArchiveBuilder<'a> {
|
impl<'a> ArArchiveBuilder<'a> {
|
||||||
fn add_archive<F>(&mut self, archive_path: PathBuf, mut skip: F) -> io::Result<()>
|
fn add_archive<F>(&mut self, archive_path: PathBuf, mut skip: F) -> io::Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(&str) -> bool + 'static,
|
F: FnMut(&str) -> bool,
|
||||||
{
|
{
|
||||||
let read_cache = ReadCache::new(std::fs::File::open(&archive_path)?);
|
let read_cache = ReadCache::new(std::fs::File::open(&archive_path)?);
|
||||||
let archive = ArchiveFile::parse(&read_cache).unwrap();
|
let archive = ArchiveFile::parse(&read_cache).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user