url: optimize URLSearchParams set/delete duplicate handling#62266
url: optimize URLSearchParams set/delete duplicate handling#62266gurgunday wants to merge 2 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62266 +/- ##
==========================================
- Coverage 89.68% 89.68% -0.01%
==========================================
Files 676 676
Lines 206495 206714 +219
Branches 39537 39583 +46
==========================================
+ Hits 185204 185393 +189
- Misses 13435 13446 +11
- Partials 7856 7875 +19
🚀 New features to boost your workflow:
|
|
@gurgunday can we split this PR in two, so we can have benchmark introduced first and then the improvements? Or maybe split in two commits, then we can try use the benchmark commit as base to test the improvements on our CI. |
|
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1812/ Results |
lib/internal/url.js
Outdated
| const list = this.#searchParams; | ||
| name = StringPrototypeToWellFormed(`${name}`); | ||
| value = StringPrototypeToWellFormed(`${value}`); | ||
| const len = list.length; |
There was a problem hiding this comment.
What's the point of declaring a variable we use once?
nit:
| const len = list.length; | |
| const { length } = list; |
There was a problem hiding this comment.
it's a habit of mine from the days when hoisting the length before for loops was faster
i can remove it if you'd like, but i applied your suggestion
There was a problem hiding this comment.
and we do access it one more time later :)
This changes set and delete to use a single pass instead of repeated array.splice() while scanning
master:
branch: