-
-
Notifications
You must be signed in to change notification settings - Fork 672
add basic String#localeCompare #1008
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
add basic String#localeCompare #1008
Conversation
// <SP>, <TAB>, <LF>, <VT>, <FF>, <CR> and <NBSP> | ||
return c == 0x20 || <u32>(c - 0x09) <= 0x0D - 0x09 || c == 0xA0; | ||
// @ts-ignore: cast | ||
return ((c | 0x80) == 0xA0) | (u32(c - 0x09) <= 0x0D - 0x09); |
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 you explain what changed here?
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.
Sure. If we slightly rearrange original condition as:
(c == 0x20 || c == 0xA0) || <u32>(c - 0x09) <= 0x0D - 0x09
and convert 0x20
and 0xA0
to binary:
0b00100000 // 0x20
0b10100000 // 0xA0
// also
0b10000000 // 0x80
we could see (c | 0b10000000) == 0b10100000
always true
for 0b00100000
or 0b10100000
and false
overwise
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.
Added comment
No description provided.