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

Improve speed of to_string for Classes #772

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/virtual_dom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ impl Classes {

impl ToString for Classes {
fn to_string(&self) -> String {
let mut buf = String::new();
for class in &self.set {
buf.push_str(class);
buf.push(' ');
}
buf.pop();
buf
self.set
.iter()
.map(String::as_str)
.collect::<Vec<&str>>()
Copy link
Member

@jstarry jstarry Dec 4, 2019

Choose a reason for hiding this comment

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

@hgzimmerman could you please add benchmark results to PRs with perf changes like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

How do you suggest that they be integrated into the project?

This one would be easy enough to copy relevant code into a separate project, run the benchmark and throw the project away when done.
Or instead should a benchmarks directory (analogous to tests or examples) be created?
Or finally, just leave a benchmark as part of a tests or benchmarks module within the existing file?

While I await your response, I'll pursue the first option.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I was suggesting running benchmarks locally and pasting the results (ideally in the PR description). I'll add a formal process for this soon

.join(" ")
}
}

Expand Down