Commit ccd59e7
committed
http: skip byte length scan for latin1 writes
Single byte encodings have a byte length equal to the string length, so
measuring them with `Buffer.byteLength()` is wasted work. Every write
this module makes internally — the header block, the chunk size lines
and the trailer — is latin1, so they were all paying for a scan that
could only return `data.length`.
Check for those encodings before measuring. This takes the overhead of
the previous commit on a chunked write from ~13% to ~5%, and leaves
utf8 bodies, which do have to be measured, unaffected.
Refs: #57985
Signed-off-by: Ali Ahmed <ali.lah.aed456@gmail.com>1 parent cbb1789 commit ccd59e7
1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
469 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
470 | 474 | | |
471 | 475 | | |
472 | 476 | | |
| |||
0 commit comments