-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Micro-optimize OutputFilenames #68409
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with my comment resolved
src/librustc_session/config.rs
Outdated
let mut s = String::with_capacity(self.out_filestem.len() + self.extra.len()); | ||
s.push_str(&self.out_filestem); | ||
s.push_str(&self.extra); | ||
s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can go a bit further here -- we don't modify the out_filestem and extra after construction, so a few more optimizations can apply here, see https://github.com/Mark-Simulacrum/rust/pull/new/output-filenames-opt -- if you steal the commits/changes from there, then that'll push this even closer to optimal :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've added your commits to this PR.
We already have ownership of the base path, so no need to clone it (within Path::with_extension).
@bors r+ |
📌 Commit dc97181 has been approved by |
Micro-optimize OutputFilenames For example, its methods consume 6% of time during debug-compiling a `warp` example: ![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png) This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
Micro-optimize OutputFilenames For example, its methods consume 6% of time during debug-compiling a `warp` example: ![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png) This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
Micro-optimize OutputFilenames For example, its methods consume 6% of time during debug-compiling a `warp` example: ![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png) This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
Micro-optimize OutputFilenames For example, its methods consume 6% of time during debug-compiling a `warp` example: ![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png) This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
Rollup of 10 pull requests Successful merges: - #67195 ([experiment] Add `-Z no-link` flag) - #68253 (add bare metal ARM Cortex-A targets to rustc) - #68361 (Unbreak linking with lld 9 on FreeBSD 13.0-CURRENT i386) - #68388 (Make `TooGeneric` error in WF checking a proper error) - #68409 (Micro-optimize OutputFilenames) - #68410 (Export weak symbols used by MemorySanitizer) - #68425 (Fix try-op diagnostic in E0277 for methods) - #68440 (bootstrap: update clippy subcmd decription) - #68441 (pprust: use as_deref) - #68462 (librustc_mir: don't allocate vectors where slices will do.) Failed merges: r? @ghost
For example, its methods consume 6% of time during debug-compiling a
warp
example:This PR optimize them a bit by using
PathBuf::set_extension
instead ofPath::with_extension
, to avoid cloningPathBuf
excessively.