rustc/session: improve allocations
This commit is contained in:
parent
942a79615b
commit
675f00bfa8
4 changed files with 7 additions and 6 deletions
|
|
@ -490,10 +490,10 @@ pub enum Input {
|
|||
}
|
||||
|
||||
impl Input {
|
||||
pub fn filestem(&self) -> String {
|
||||
pub fn filestem(&self) -> &str {
|
||||
match *self {
|
||||
Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap().to_string(),
|
||||
Input::Str { .. } => "rust_out".to_string(),
|
||||
Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap(),
|
||||
Input::Str { .. } => "rust_out",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1406,6 +1406,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||
let atomic_cas = sess.target.target.options.atomic_cas;
|
||||
|
||||
let mut ret = FxHashSet::default();
|
||||
ret.reserve(6); // the minimum number of insertions
|
||||
// Target bindings.
|
||||
ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os))));
|
||||
if let Some(ref fam) = sess.target.target.options.target_family {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ impl<'a> FileSearch<'a> {
|
|||
F: FnMut(&Path, PathKind)
|
||||
{
|
||||
let mut visited_dirs = FxHashSet::default();
|
||||
|
||||
visited_dirs.reserve(self.search_paths.paths.len() + 1);
|
||||
for (path, kind) in self.search_paths.iter(self.kind) {
|
||||
f(path, kind);
|
||||
visited_dirs.insert(path.to_path_buf());
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use session::{early_error, config};
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SearchPaths {
|
||||
paths: Vec<(PathKind, PathBuf)>,
|
||||
crate paths: Vec<(PathKind, PathBuf)>,
|
||||
}
|
||||
|
||||
pub struct Iter<'a> {
|
||||
|
|
|
|||
|
|
@ -1657,7 +1657,7 @@ pub fn build_output_filenames(
|
|||
.crate_name
|
||||
.clone()
|
||||
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
|
||||
.unwrap_or_else(|| input.filestem());
|
||||
.unwrap_or_else(|| input.filestem().to_owned());
|
||||
|
||||
OutputFilenames {
|
||||
out_directory: dirpath,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue