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

Use the new fs_read_write functions in rustc internals #47328

Merged
merged 1 commit into from
Jan 12, 2018

Conversation

mbrubeck
Copy link
Contributor

Uses fs::read and fs::write (added by #45837) where appropriate, to simplify code and dog-food these new APIs. This also improves performance, when combined with #47324.

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

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

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2018
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);
Copy link
Member

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?

Copy link
Contributor Author

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

let mut contents = Vec::new();
File::open(&p).and_then(|mut f| f.read_to_end(&mut contents))?;

let contents = fs::read(&p)?;
Copy link
Member

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.

@mbrubeck
Copy link
Contributor Author

Addressed review comments.

@sfackler
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jan 10, 2018

📌 Commit 3f9c057 has been approved by sfackler

kennytm added a commit to kennytm/rust that referenced this pull request Jan 11, 2018
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.
kennytm added a commit to kennytm/rust that referenced this pull request Jan 11, 2018
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.
bors added a commit that referenced this pull request Jan 11, 2018
Rollup of 12 pull requests

- Successful merges: #47283, #47288, #47289, #47298, #47305, #47307, #47310, #47322, #47324, #47328, #47340, #47344
- Failed merges:
bors added a commit that referenced this pull request Jan 12, 2018
Rollup of 12 pull requests

- Successful merges: #47283, #47288, #47289, #47298, #47305, #47307, #47310, #47322, #47324, #47328, #47340, #47344
- Failed merges:
kennytm added a commit to kennytm/rust that referenced this pull request Jan 12, 2018
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.
bors added a commit that referenced this pull request Jan 12, 2018
@bors bors merged commit 3f9c057 into rust-lang:master Jan 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants