-
Notifications
You must be signed in to change notification settings - Fork 5.4k
refactor: accumulator spread in reduce #37435
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
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/core-extension-ux (1 files, +34 -32)
🧪 @MetaMask/qa (1 files, +10 -12)
|
Builds ready [d33409b]
UI Startup Metrics (1218 ± 71 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [41a2b7f]
UI Startup Metrics (1222 ± 68 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
seaona
left a comment
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.
nice change! LGMT
vinnyhoward
left a comment
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.
Nice work. I might do the same thing for mobile if similar patterns exist. Approved
Description
Improve readability and performance
Spreading the accumulator can generally be slower than a simple for loop, not to mention less readable
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Refactors multiple reducers using spread into explicit loops/Object.assign for building maps, arrays, and initial state across controllers, selectors, UI, tests, and constants.
app/scripts/constants/sentry-state.ts: Replacereduce+ spread with loop andObject.assignto buildflattenedBackgroundStateMask.app/scripts/controller-init/assets/network-enablement-controller-init.ts: BuildallEnabledNetworksvia loop andObject.assign.app/scripts/controllers/metametrics-controller.ts: Rework#buildValidTraitsto usefor...ofaccumulation; preserve validation and return shape.app/scripts/lib/ComposableObservableStore.js: UseObject.assignwhen merging child states ingetFlatState.shared/constants/tokens.js: BuildSTATIC_MAINNET_TOKEN_LISTvia loop; switch to named export after declaration.shared/modules/selectors/networks.ts: BuildclientIdsByChainvia loop; ingetNetworksByScopes, useconcatinstead of array spread.ui/selectors/multichain/networks.ts: Construct EVM multichain config map via loop.ui/selectors/selectors.js: Mutate accumulator object in accounts reduce instead of returning new object each iteration.ui/components/app/contact-list/contact-list.component.js: Group contacts by letter using explicit loops and pre-allocated buckets.ui/components/multichain/.../asset-picker-modal-network.tsx: Initialize and updatecheckedChainIdsvia loops; rework "select all" toggle to build a new map.test/e2e/fixture-builder.js: BuildoptionalScopesfor multichain test dapp using a loop.Written by Cursor Bugbot for commit 41a2b7f. This will update automatically on new commits. Configure here.