Uh oh!
There was an error while loading. Please reload this page.
readline: use icu based string width calculation - #9040
Conversation
jasnell
commented
Oct 11, 2016
Technically semver-minor because it allows now a single codepoint to be passed in as the argument to |
jasnell
commented
Oct 12, 2016
bnoordhuis
commented
Oct 12, 2016
This change would make intl and non-intl builds behave differently, wouldn't it? I think I'd rather have a single semi-broken algorithm than two diverging implementations. As well, the non-intl path will be untested until nodejs/build#419 is resolved. |
jasnell
commented
Oct 12, 2016
Intl and non-intl builds already behave differently in many ways. This On Wednesday, October 12, 2016, Ben Noordhuis notifications@github.com
|
bnoordhuis
commented
Oct 12, 2016
Oh? In what way?
"Everyone is doing it" is never a valid argument. V8 is not under our direct control but this is. |
jasnell
commented
Oct 12, 2016
Off the top of my head:
There's likely more. It's also not just about a more accurate implementation, performance is also significantly improved with the new algorithm. this PR: vs. latest v6: (the benchmark test benchmark/misc/stringwidth.js is not part of this PR currently, it's local on my machine) |
There was a problem hiding this comment.
maybe we should initially assign no-ops with comments?
There was a problem hiding this comment.
how come? that does not seem very practical.
There was a problem hiding this comment.
not detectable from process.config?
There was a problem hiding this comment.
Using process.config is unreliable because there are userland packages that override it. That's why process.binding('config') was introduced.
There was a problem hiding this comment.
shouldn't this remain isNaN() ... or rather, Number.isNaN()?
There was a problem hiding this comment.
maybe add a comment about these values?
There was a problem hiding this comment.
is the existing comment on line 128 and 129 not enough?
c133999 to
83c7a88CompareNew CI: https://ci.nodejs.org/job/node-test-pull-request/4611/ |
jasnell
commented
Oct 22, 2016
Only unrelated flaky failures in CI. @nodejs/collaborators would appreciate additional review. |
bnoordhuis
left a comment
There was a problem hiding this comment.
FWIW, I still don't think this should land until we have a proper non-intl buildbot. So far, almost every intl-related change broke the non-intl build in one way or another.
There was a problem hiding this comment.
This regex could use a comment explaining what it tries to match/capture. Also, four space indent.
There was a problem hiding this comment.
four space indent would make the line longer than 80 chars, and splitting the regex into multiple lines would make it less readable. I'd prefer to leave the spacing as is.
There was a problem hiding this comment.
Style: s/ambiguousFull/ambiguous_full/ here and elsewhere. I don't like the name very much, it doesn't really convey what it does.
There was a problem hiding this comment.
Why UCHAR_EAST_ASIAN_WIDTH? This needs an explaining comment.
There was a problem hiding this comment.
If the fall-through is intentional, can you add // fallthrough comments?
There was a problem hiding this comment.
Maybe put braces around the body, slightly easier to read.
There was a problem hiding this comment.
The reinterpret_cast shouldn't be necessary, should it?
jasnell
commented
Oct 23, 2016
Updated to address the nits. |
jasnell
commented
Oct 23, 2016
@bnoordhuis ... added a nointl CI job we can run manually: https://ci.nodejs.org/job/node-test-commit-linux-nointl/1/ |
jbergstroem
commented
Oct 23, 2016
@jasnell: I don't think it should be added to the current job as-is. There's way too many workers involved. Do we need to test this on every linux flavor? I was hoping to have a small subset of workers for build permutation tests. |
Updated. Needs another review from @bnoordhuis
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM with a comment and a style nit.
There was a problem hiding this comment.
TwoByteValue's constructor takes a Local<Value>. It's arguably wrong to cast because there is no check that it's really a string so I'd just let the constructor deal with this.
srl295
left a comment
There was a problem hiding this comment.
Looks good, with a couple of minor comments
There was a problem hiding this comment.
U+200D is a ZWJ (zero width joiner), please use that term
There was a problem hiding this comment.
This seems like a reasoable way of doing this calculation
There was a problem hiding this comment.
It may be worth referencing something like http://www.unicode.org/reports/tr11/#Ambiguous here
jasnell
commented
Oct 24, 2016
Updated with the final nits addressed. New CI: https://ci.nodejs.org/job/node-test-pull-request/4655/ |
jasnell
commented
Oct 25, 2016
had a compile nit pop up on windows... trying again https://ci.nodejs.org/job/node-test-pull-request/4664/ |
Rather than the pseudo-wcwidth impl used currently, use the ICU character properties database to calculate string width and determine if a character is full width or not. This allows the algorithm to correctly identify emoji's as full width, ensures the algorithm will continue to fucntion properly as new unicode codepoints are added, and it's faster. This was originally part of a proposal to add a new unicode module, but has been split out. Refs: nodejs#8075
jasnell
commented
Oct 25, 2016
CI is green except for unrelated flaky failures. Landing |
Rather than the pseudo-wcwidth impl used currently, use the ICU character properties database to calculate string width and determine if a character is full width or not. This allows the algorithm to correctly identify emoji's as full width, ensures the algorithm will continue to fucntion properly as new unicode codepoints are added, and it's faster. This was originally part of a proposal to add a new unicode module, but has been split out. Refs: #8075 PR-URL: #9040 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
jasnell
commented
Oct 25, 2016
Landed in 72547fe |
jasnell
commented
Oct 25, 2016
Shrinking it down ought to be fine. I'll do that this next week On Sunday, October 23, 2016, Johan Bergström notifications@github.com
|
bnoordhuis
commented
Oct 25, 2016
@jasnell g++ spotted a bug: I think you need a U16_NEXT call outside the loop. |
jasnell
commented
Oct 25, 2016
Hmm.. Ok, away from the laptop at the moment but will look at that shortly |
srl295
commented
Oct 25, 2016
@bnoordhuis good catch - otherwise A |
bnoordhuis
commented
Oct 25, 2016
Rather than the pseudo-wcwidth impl used currently, use the ICU character properties database to calculate string width and determine if a character is full width or not. This allows the algorithm to correctly identify emoji's as full width, ensures the algorithm will continue to fucntion properly as new unicode codepoints are added, and it's faster. This was originally part of a proposal to add a new unicode module, but has been split out. Refs: #8075 PR-URL: #9040 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
MylesBorins
commented
May 15, 2017
/cc @srl295 currently passing on this being backported to v6.x. Do you think it should be considered? |
jasnell
commented
May 15, 2017
I'm not @srl295, of course, but I'll chime in to say that I see no pressing reason to backport this |
srl295
commented
Aug 31, 2017
no pressing reason |
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
readline, internal
Description of change
Rather than the pseudo-wcwidth impl used currently, use the ICU character properties database to calculate string width and determine if a character is full width or not. This allows the algorithm to correctly identify emoji's as full width, ensures the algorithm will continue to fucntion properly as new unicode codepoints are added, and it's faster.
This was originally part of a proposal to add a new unicode module, but has been split out.
Refs: #8075