-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(index): use spread over Object.assign()
#257
Conversation
object.assign()
Object.assign()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it is not noticable for most cases. If you use a delegator, then you should notice. |
Learnt something new today, thanks @Uzlopak! Not worth looking at in other repos then? |
I wouldnt say that. Here in fastify-cors if you dont use that delegator style, than you will call that object merging only once. If you use delegator than it should be merging the object on every request. But there are potentially other repos where object merging happens on every request and not only on startup, where it is worth to investigate it further. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@fastify/cors](https://github.com/fastify/fastify-cors) | [`8.3.0` -> `8.4.0`](https://renovatebot.com/diffs/npm/@fastify%2fcors/8.3.0/8.4.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@fastify%2fcors/8.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@fastify%2fcors/8.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@fastify%2fcors/8.3.0/8.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@fastify%2fcors/8.3.0/8.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>fastify/fastify-cors (@​fastify/cors)</summary> ### [`v8.4.0`](https://github.com/fastify/fastify-cors/releases/tag/v8.4.0) [Compare Source](https://github.com/fastify/fastify-cors/compare/v8.3.0...v8.4.0) #### What's Changed - fix documentation, onRequest is default lifecycle stage by [@​Uzlopak](https://github.com/Uzlopak) in [https://github.com/fastify/fastify-cors/pull/254](https://github.com/fastify/fastify-cors/pull/254) - perf(index): use spread over `Object.assign()` by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/257](https://github.com/fastify/fastify-cors/pull/257) - docs(readme): add plugin compatibility table by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/258](https://github.com/fastify/fastify-cors/pull/258) - test: cors headers sent when payload is stream by [@​Uzlopak](https://github.com/Uzlopak) in [https://github.com/fastify/fastify-cors/pull/260](https://github.com/fastify/fastify-cors/pull/260) - Reduce bundle size by [@​timedtext](https://github.com/timedtext) in [https://github.com/fastify/fastify-cors/pull/266](https://github.com/fastify/fastify-cors/pull/266) - chore(deps-dev): bump [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) from 5.62.0 to 6.4.1 by [@​dependabot](https://github.com/dependabot) in [https://github.com/fastify/fastify-cors/pull/267](https://github.com/fastify/fastify-cors/pull/267) - chore(deps-dev): bump tsd from 0.28.1 to 0.29.0 by [@​dependabot](https://github.com/dependabot) in [https://github.com/fastify/fastify-cors/pull/268](https://github.com/fastify/fastify-cors/pull/268) - test: use `node:` prefix to bypass require.cache call for builtins by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/269](https://github.com/fastify/fastify-cors/pull/269) - refactor(vary): use word character inside regex character class by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/270](https://github.com/fastify/fastify-cors/pull/270) #### New Contributors - [@​timedtext](https://github.com/timedtext) made their first contribution in [https://github.com/fastify/fastify-cors/pull/266](https://github.com/fastify/fastify-cors/pull/266) **Full Changelog**: fastify/fastify-cors@v8.3.0...v8.4.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tomacheese/telcheck). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi45Ny4xIiwidXBkYXRlZEluVmVyIjoiMzYuOTcuMSIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@fastify/cors](https://github.com/fastify/fastify-cors) | [`8.3.0` -> `8.4.1`](https://renovatebot.com/diffs/npm/@fastify%2fcors/8.3.0/8.4.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@fastify%2fcors/8.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@fastify%2fcors/8.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@fastify%2fcors/8.3.0/8.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@fastify%2fcors/8.3.0/8.4.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>fastify/fastify-cors (@​fastify/cors)</summary> ### [`v8.4.1`](https://github.com/fastify/fastify-cors/releases/tag/v8.4.1) [Compare Source](https://github.com/fastify/fastify-cors/compare/v8.4.0...v8.4.1) #### What's Changed - Fix type of OriginCallback by [@​ken-browning](https://github.com/ken-browning) in [https://github.com/fastify/fastify-cors/pull/272](https://github.com/fastify/fastify-cors/pull/272) - test: add `u` unicode flag to regex by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/273](https://github.com/fastify/fastify-cors/pull/273) - chore(package): explicitly declare js module type by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/274](https://github.com/fastify/fastify-cors/pull/274) - test(index): replace `typeof` undefined check by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/275](https://github.com/fastify/fastify-cors/pull/275) #### New Contributors - [@​ken-browning](https://github.com/ken-browning) made their first contribution in [https://github.com/fastify/fastify-cors/pull/272](https://github.com/fastify/fastify-cors/pull/272) **Full Changelog**: fastify/fastify-cors@v8.4.0...v8.4.1 ### [`v8.4.0`](https://github.com/fastify/fastify-cors/releases/tag/v8.4.0) [Compare Source](https://github.com/fastify/fastify-cors/compare/v8.3.0...v8.4.0) #### What's Changed - fix documentation, onRequest is default lifecycle stage by [@​Uzlopak](https://github.com/Uzlopak) in [https://github.com/fastify/fastify-cors/pull/254](https://github.com/fastify/fastify-cors/pull/254) - perf(index): use spread over `Object.assign()` by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/257](https://github.com/fastify/fastify-cors/pull/257) - docs(readme): add plugin compatibility table by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/258](https://github.com/fastify/fastify-cors/pull/258) - test: cors headers sent when payload is stream by [@​Uzlopak](https://github.com/Uzlopak) in [https://github.com/fastify/fastify-cors/pull/260](https://github.com/fastify/fastify-cors/pull/260) - Reduce bundle size by [@​timedtext](https://github.com/timedtext) in [https://github.com/fastify/fastify-cors/pull/266](https://github.com/fastify/fastify-cors/pull/266) - chore(deps-dev): bump [@​typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/eslint-plugin) from 5.62.0 to 6.4.1 by [@​dependabot](https://github.com/dependabot) in [https://github.com/fastify/fastify-cors/pull/267](https://github.com/fastify/fastify-cors/pull/267) - chore(deps-dev): bump tsd from 0.28.1 to 0.29.0 by [@​dependabot](https://github.com/dependabot) in [https://github.com/fastify/fastify-cors/pull/268](https://github.com/fastify/fastify-cors/pull/268) - test: use `node:` prefix to bypass require.cache call for builtins by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/269](https://github.com/fastify/fastify-cors/pull/269) - refactor(vary): use word character inside regex character class by [@​Fdawgs](https://github.com/Fdawgs) in [https://github.com/fastify/fastify-cors/pull/270](https://github.com/fastify/fastify-cors/pull/270) #### New Contributors - [@​timedtext](https://github.com/timedtext) made their first contribution in [https://github.com/fastify/fastify-cors/pull/266](https://github.com/fastify/fastify-cors/pull/266) **Full Changelog**: fastify/fastify-cors@v8.3.0...v8.4.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 4pm every weekday" in timezone Europe/Paris, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/specfy/specfy). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6ImNob3JlL3Jlbm92YXRlQmFzZUJyYW5jaCJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Nearly twice as fast, see https://github.com/RafaelGSS/nodejs-bench-operations/blob/main/RESULTS-v18.md#objectassign-vs-spread-operator
Checklist
npm run test
andnpm run benchmark
and the Code of conduct