-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix BytePos -> CharPos calculations #6574
Conversation
There were a few issues in the old code: 1. UTF-8 maps 1-3 bytes into 1 UTF-16 char, but 4 bytes into 2 UTF-16 chars 2. The starting offset was not recorded when we end the `multibyte_chars` iteration 3. The `mappings` can be unordered, meaning we need to restart UTF-16 offset calculation
a4b8c38
to
ef0c185
Compare
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.
Thank you so much!
swc-bump:
- swc_common
Sorry, I just pushed a reverse conversion for when the mapping isn't ordered. This hopefully makes it a bit faster. |
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.
Thank you!
Ah, one of my recent changes is causing a failure. Working to fix it now. |
Should be good now. |
Can you explain how you're doing the benchmark? I'm actually seeing an ~2% improvement with that file running |
Let's fix performance regression with another PR.. |
Sorry, you are right, I just using the wrong branch. No performance regression. |
Description:
This fixes the BytePos -> CharPos calculation necessary for source maps. There were a few issues in the old code:
multibyte_chars
iterationmappings
can be unordered, meaning we need to restart UTF-16 offset calculationBREAKING CHANGE:
Related issue (if exists):
Fixes #6552