Commit f58c120
src: fix inefficient usage of v8_inspector::StringView
v8_inspector::StringView can either be one-byte or two-byte strings.
Node has currently two places where it's unconditionally assumed that
it's a two-byte StringView.
This requires the upstream V8 inspector to unnecessarily create
a copy of the string:
https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/v8-inspector-session-impl.cc;l=192-199;drc=05bacd38e7a31e92afe0fd66081dfa2cc03b934a
This is particularly slow, especially for large CDP messages, as the
serialized JSON is iterated 8-bit char by 8-bit char and each one
widened to a 16-bit char.
This PR introduces a small helper that correctly converts a StringView
to a v8::String instance honoring the "is8Bit" flag. This allows
upstream V8 to remove the unnecessary widening copy.
PR-URL: #52372
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>1 parent 7e195ec commit f58c120
3 files changed
+32
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 71 | + | |
| 72 | + | |
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
347 | 373 | | |
348 | 374 | | |
349 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
719 | 720 | | |
720 | 721 | | |
721 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
722 | 726 | | |
723 | 727 | | |
724 | 728 | | |
| |||
0 commit comments