Skip to content

util: reduce javascript call for ToUSVString

ToUSVString is mostly called with small inputs and optimizing it for very large strings does not reflect the real-world usage. Removing RegExpPrototypeExec from JavaScript improves things.

                                        confidence improvement accuracy (*)   (**)  (***)
util/to-usv-string.js size=10 n=100000         ***     38.74 %       ±2.10% ±2.82% ±3.73%
util/to-usv-string.js size=100 n=100000        ***      7.42 %       ±0.60% ±0.80% ±1.04%
util/to-usv-string.js size=500 n=100000        ***      1.21 %       ±0.50% ±0.66% ±0.86%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 3 comparisons, you can thus expect the following amount of false-positive results:
  0.15 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.03 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

cc @nodejs/util

Merge request reports

Loading