1
Fork 0

Rollup merge of #123827 - petrochenkov:searchdirs, r=Nadrieril

linker: Avoid some allocations in search directory iteration

This is more a cleanup than actual optimization.
This commit is contained in:
Matthias Krüger 2024-04-12 04:38:23 +02:00 committed by GitHub
commit 7f111834ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 22 deletions

View file

@ -17,12 +17,12 @@ use rustc_target::spec::abi::Abi;
use crate::errors;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
pub fn find_native_static_library(
pub fn find_native_static_library<'a>(
name: &str,
verbatim: bool,
search_paths: &[PathBuf],
search_paths: impl Iterator<Item = &'a Path>,
sess: &Session,
) -> PathBuf {
let formats = if verbatim {
@ -60,7 +60,7 @@ fn find_bundled_library(
&& (sess.opts.unstable_opts.packed_bundled_libs || has_cfg || whole_archive == Some(true))
{
let verbatim = verbatim.unwrap_or(false);
let search_paths = &sess.target_filesearch(PathKind::Native).search_path_dirs();
let search_paths = sess.target_filesearch(PathKind::Native).search_path_dirs();
return find_native_static_library(name.as_str(), verbatim, search_paths, sess)
.file_name()
.and_then(|s| s.to_str())