-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Use the new fs_read_write functions in rustc internals #47328
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustdoc/html/render.rs
Outdated
let mut f = try_err!(File::open(css), css); | ||
|
||
try_err!(f.read_to_string(&mut content), css); | ||
let content = try_err!(fs::read(&css), &css); |
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.
This should be read_string
, right?
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.
The original used read_to_string
but there's no reason to create a string here; it's just copying the contents to a new file. Actually, this should use fs::copy
...
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.
Fixed.
src/librustdoc/html/render.rs
Outdated
let mut contents = Vec::new(); | ||
File::open(&p).and_then(|mut f| f.read_to_end(&mut contents))?; | ||
|
||
let contents = fs::read(&p)?; |
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.
This can be read_string
.
Addressed review comments. |
@bors r+ |
📌 Commit 3f9c057 has been approved by |
Use the new fs_read_write functions in rustc internals Uses `fs::read` and `fs::write` (added by rust-lang#45837) where appropriate, to simplify code and dog-food these new APIs. This also improves performance, when combined with rust-lang#47324.
Use the new fs_read_write functions in rustc internals Uses `fs::read` and `fs::write` (added by rust-lang#45837) where appropriate, to simplify code and dog-food these new APIs. This also improves performance, when combined with rust-lang#47324.
Use the new fs_read_write functions in rustc internals Uses `fs::read` and `fs::write` (added by rust-lang#45837) where appropriate, to simplify code and dog-food these new APIs. This also improves performance, when combined with rust-lang#47324.
Uses
fs::read
andfs::write
(added by #45837) where appropriate, to simplify code and dog-food these new APIs. This also improves performance, when combined with #47324.