-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Clarification on performance improvements in std::fs::read_to_string for Windows #130600
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.O-windowsOperating system: WindowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.O-windowsOperating system: WindowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Location
Function
read_to_stringinstd::fshttps://doc.rust-lang.org/stable/std/fs/fn.read_to_string.html
Summary
The current documentation for
std::fs::read_to_stringstates that it is a convenience function forFile::openandstd::io::Read::read_to_string, providing fewer imports and no intermediate variables. However, after the recent pull request #110655, it seems thatstd::fs::read_to_stringhas received performance improvements specifically for Windows, addressing issues thatFile::openandstd::io::Read::read_to_stringstill face on this platform.This implies that using
std::fs::read_to_stringis not just a matter of convenience, but may also result in better performance on Windows compared to manually combiningFile::openandstd::io::Read::read_to_string.I believe this performance improvement should be mentioned in the documentation, especially for developers targeting Windows, as the current documentation only emphasizes the convenience aspect without mentioning the performance benefits.
Suggested change:
Add a note to the documentation of
std::fs::read_to_string, clarifying that due to recent improvements in pull request #110655, it offers better performance on Windows than manually usingFile::openandstd::io::Read::read_to_string.Thank you for your consideration!