perf(request): probe the body cache without allocating (#5176)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
`#cachedBody` used `Object.keys(bodyCache)[0]` to find any already cached body, allocating a fresh array on every body read (`req.json()`, `req.text()`, ...) just to read one element. A `for ... in` loop that returns on its first iteration gives the same first-key-by-insertion-order result with no allocation. `bodyCache` is a plain object literal, so there are no enumerable prototype keys to consider.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+1 added−2 removed
- other:+1 added−2 removed