-
-
Notifications
You must be signed in to change notification settings - Fork 670
optimize UTF8 conversion routines #1022
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
optimize UTF8 conversion routines #1022
Conversation
if ((u0 & 240) == 224) { | ||
u0 = (u0 & 15) << 12 | u1 << 6 | u2; | ||
} else { | ||
if (bufEnd == bufOff) break; |
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.
On a first glimpse this seems to be trading branches, like where we previously checked that we can process 3 bytes (never emitting truncated bytes), we now check per byte (potentially emitting truncated bytes?). Makes me wonder what's better.
if (nullTerminated && !c1) break; | ||
bufLen += 1; strOff += 2; | ||
// @ts-ignore: cast | ||
if (nullTerminated & !c1) break; |
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.
Can also do u32(nullTerminated) & u32(!c1)
here to avoid the ts-ignore.
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.
Yes, and in first version I used exactly that but later we decide just comment with ts ignorance)
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.
It was in other PR
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.
I see, hmm. Do you remember if that was due to wrapping?
let u0 = <u32>load<u8>(bufOff); ++bufOff; | ||
if (!(u0 & 128)) { | ||
// @ts-ignore: cast | ||
if (nullTerminated & !u0) break; |
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.
Similar
No description provided.