Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate the exact capacity for 2 HashMaps #52435

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Jul 16, 2018

No description provided.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 16, 2018
@@ -220,7 +220,8 @@ pub fn write_counts(count_file: &mut File, counts: &mut HashMap<String,QueryMetr
}

pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &Vec<Rec>) {
let mut counts : HashMap<String,QueryMetric> = HashMap::new();
let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
let mut counts : HashMap<String,QueryMetric> = HashMap::with_capacity(capacity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma between String and QueryMetric.

@estebank
Copy link
Contributor

@ljedrz if you have time, please fix the formatting nitpick, in the meantime, I'm approving as is.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 16, 2018

📌 Commit 20d7ffa7b9cec959c53dd67646068901766648e0 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 16, 2018
@ljedrz
Copy link
Contributor Author

ljedrz commented Jul 16, 2018

No problem, done.

@kennytm kennytm removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 16, 2018
@kennytm
Copy link
Member

kennytm commented Jul 16, 2018

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jul 16, 2018

📌 Commit d85bcef has been approved by estebank

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 16, 2018
@@ -51,7 +51,7 @@ pub fn build(build: &mut Build) {
build_krate("", build, &mut resolves, "src/libtest");
build_krate(&build.rustc_features(), build, &mut resolves, "src/rustc");

let mut id2name = HashMap::new();
let mut id2name = HashMap::with_capacity(build.crates.len());
for (name, krate) in build.crates.iter() {
id2name.insert(krate.id.clone(), name.clone());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, this one could also be done with map() followed by collect().

kennytm added a commit to kennytm/rust that referenced this pull request Jul 17, 2018
Calculate the exact capacity for 2 HashMaps
bors added a commit that referenced this pull request Jul 17, 2018
Rollup of 9 pull requests

Successful merges:

 - #52286 (Deny bare trait objects in src/librustc_errors)
 - #52306 (Reduce the number of clone()s needed in obligation_forest)
 - #52338 (update miri)
 - #52385 (Pass edition flags to compiler from rustdoc as expected)
 - #52392 (AsRef doc wording tweaks)
 - #52430 (update nomicon)
 - #52434 (Enable incremental independent of stage)
 - #52435 (Calculate the exact capacity for 2 HashMaps)
 - #52446 (Block beta if clippy breaks.)

r? @ghost
@bors bors merged commit d85bcef into rust-lang:master Jul 17, 2018
@ljedrz ljedrz deleted the misc_capacity branch July 17, 2018 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants