Skip to content

Commit

Permalink
rustc/session: improve allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Oct 15, 2018
1 parent 942a796 commit 675f00b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/librustc/session/config.rs
Expand Up @@ -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",
}
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/filesearch.rs
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/search_paths.rs
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/driver.rs
Expand Up @@ -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,
Expand Down

0 comments on commit 675f00b

Please sign in to comment.