lib: add ASCII fast path to getStringWidth()
A lot of strings that are going to be passed to `getStringWidth()`
are ASCII strings, for which the calculation is rather easy and
calling into C++ can be skipped.
confidence improvement accuracy (*) (**) (***)
misc/getstringwidth.js n=100000 type='ascii' *** 328.99 % ±21.73% ±29.25% ±38.77%
misc/getstringwidth.js n=100000 type='emojiseq' 2.94 % ±7.66% ±10.19% ±13.26%
misc/getstringwidth.js n=100000 type='fullwidth' 4.70 % ±5.64% ±7.50% ±9.76%
PR-URL: https://github.com/nodejs/node/pull/29301
Reviewed-By:
Gus Caplan <me@gus.host>
Reviewed-By:
Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By:
Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By:
Colin Ihrig <cjihrig@gmail.com>
Reviewed-By:
James M Snell <jasnell@gmail.com>
Reviewed-By:
Luigi Pinca <luigipinca@gmail.com>
Reviewed-By:
Minwoo Jung <minwoo@nodesource.com>
Reviewed-By:
Rich Trott <rtrott@gmail.com>
parent
020c2eaf
Please register or sign in to comment