Conversation
|
Node: 14 Node: 16 Node: 18 |
|
I think the impact is minimal. Pull Request Main Branch |
|
Would nodejs/node#43115, as mentioned in the other PR, not tackle this? |
It can handle it, but the that issue seems no activity. If the impact is small enough (fall between the variation), I think we can land it first. |
|
What issue does this solve? |
|
| return function validateHTTPVersion (httpVersion) { | ||
| // `bypass` skip the check when custom server factory provided | ||
| // `httpVersion in obj` check for the valid http version we should support | ||
| return bypass || httpVersion in obj |
There was a problem hiding this comment.
What would the difference be in using an actual Map and then a .has check?
| return bypass || httpVersion in obj | |
| return bypass || obj.has(httpVersion) |
There was a problem hiding this comment.
Map is definitely slower in this case.
I also tested Set, it is about the same as Array.includes.
I re-run the benchmark. Map actually about the same as in operator.
using Map.has x 1,295,809,605 ops/sec ±0.09% (98 runs sampled)
using Map.has (first item) x 1,293,557,094 ops/sec ±0.12% (96 runs sampled)
using Set.has x 145,554,007 ops/sec ±0.65% (91 runs sampled)
using Set.has (first item) x 147,771,297 ops/sec ±0.31% (96 runs sampled)
using in obj x 1,294,797,802 ops/sec ±0.19% (94 runs sampled)
using in obj (first item) x 1,295,422,306 ops/sec ±0.05% (100 runs sampled)
using Array.includes x 127,497,843 ops/sec ±0.51% (95 runs sampled)
using Array.includes (first item) x 148,103,651 ops/sec ±0.26% (95 runs sampled)
Using raw comparisson x 512,871,599 ops/sec ±35.76% (39 runs sampled)
Using raw comparisson (first item) x 145,327,537 ops/sec ±4.66% (79 runs sampled)
Co-authored-by: James Sumners <[email protected]>
Co-authored-by: Frazer Smith <[email protected]>
|
Can you resolve the conflicts? |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #3893
Checklist
npm run testandnpm run benchmarkand the Code of conduct