-
-
Notifications
You must be signed in to change notification settings - Fork 754
refactor: drop support for non-UTF8 paths #7570
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for rspack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
Author
|
This will not be considered as a breaking change. As we does not support Rust API in the first place and strings passed from NAPI runtime are always UTF-8 encoded. |
5bf0ade to
c88403e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
Author
|
!bench |
|
📝 Benchmark detail: Open
|
This reverts commit eb70499.
Contributor
Author
|
bumped camino to support: camino-rs/camino#93 |
JSerFeng
approved these changes
Aug 20, 2024
Merged
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Enforce paths passed to rspack to UTF-8.
According to
OsString:Two paths types are received by rspack:
Stringfrom JavaScript runtime (UTF-8 encoded)Performance
Ad-hoc test : String reference -> PathBuf / Utf8PathBuf -> String
PathBuf::fromtakes inputs without UTF-8 validations,to_string_lossyvalidates ifPathBufis a valid UTF-8 string.Utf8PathBuf::fromtakes inputs without UTF-8 validations,to_stringcreates aformatterand call theas_strto validate(not if rustc version is >= 1.74 stable, perf: cost-free conversion from paths to&strcamino-rs/camino#93). (It's even faster to callas_str().to_string()instead)Comparison: PathBuf -> Utf8PathBuf -> String vs. PathBuf -> String
This is the performance generated with
benchcommand as shown below.Always choose not to call
assert_utf8if these paths are only read once. UTF-8 validation is costy.For example:
file_dependencies, etc. Check out this commit for the changes I made: 58b8b95Checklist