util: use string width in util formatPrimitive() string length line check#43721
util: use string width in util formatPrimitive() string length line check#43721Anemy wants to merge 1 commit intonodejs:mainfrom
formatPrimitive() string length line check#43721Conversation
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. |
BridgeAR
left a comment
There was a problem hiding this comment.
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.inspectformatting 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.