-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
util: use string width in util formatPrimitive()
string length line check
#43721
util: use string width in util formatPrimitive()
string length line check
#43721
Conversation
Improves support for formatting strings with unicode characters by using the string character width instead of the string length.
This comment was marked as outdated.
This comment was marked as outdated.
I would like to run a benchmark on this to make sure the performance hit is not too big. Benchmark: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1162/ |
Let's wait until our benchmarks are fixed. |
This does slow down printing strings significantly (only 2 stars and more):
I wonder if we really want this by default. We do not profit from it strongly as it is only going to be used for formatting things nicer under very special circumstances. I already feared the performance drop when I wrote the comment and did not implement it at that point due to that. |
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 suggest to just remove the comment instead to prevent the slowdown in the average case.
Follow up from benchmarks in pr: nodejs#43721
PR-URL: nodejs#43762 Refs: nodejs#43721 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs/node#43762 Refs: nodejs/node#43721 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Improves support for
util.inspect
formatting strings with unicode characters by updating to look at the string width instead of the string length.Characters like
あ
have a width of 2 and length 1.