-
-
Notifications
You must be signed in to change notification settings - Fork 562
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
refactor: drop support for non-UTF8 paths #7570
Merged
Merged
Conversation
This file contains 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
github-actions
bot
added
the
team
The issue/pr is created by the member of Rspack.
label
Aug 14, 2024
✅ 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.
h-a-n-a
changed the title
refactor: utf8 paths
refactor!: drop support for non-UTF8 paths
Aug 14, 2024
h-a-n-a
added
the
release: breaking change
release: breaking change related release(mr only)
label
Aug 14, 2024
h-a-n-a
changed the title
refactor!: drop support for non-UTF8 paths
refactor: drop support for non-UTF8 paths
Aug 14, 2024
h-a-n-a
removed
the
release: breaking change
release: breaking change related release(mr only)
label
Aug 14, 2024
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. |
h-a-n-a
force-pushed
the
refactor-path
branch
2 times, most recently
from
August 15, 2024 08:10
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.
!bench |
📝 Benchmark detail: Open
|
This reverts commit eb70499.
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:
String
from JavaScript runtime (UTF-8 encoded)Performance
Ad-hoc test : String reference -> PathBuf / Utf8PathBuf -> String
PathBuf::from
takes inputs without UTF-8 validations,to_string_lossy
validates ifPathBuf
is a valid UTF-8 string.Utf8PathBuf::from
takes inputs without UTF-8 validations,to_string
creates aformatter
and call theas_str
to validate(not if rustc version is >= 1.74 stable, perf: cost-free conversion from paths to&str
camino-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
bench
command as shown below.Always choose not to call
assert_utf8
if 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