Skip to content

Conversation

@n3ps
Copy link
Contributor

@n3ps n3ps commented Oct 31, 2025

Description

Improve readability and performance

Spreading the accumulator can generally be slower than a simple for loop, not to mention less readable

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

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.

  • Core/Controllers
    • app/scripts/constants/sentry-state.ts: Replace reduce + spread with loop and Object.assign to build flattenedBackgroundStateMask.
    • app/scripts/controller-init/assets/network-enablement-controller-init.ts: Build allEnabledNetworks via loop and Object.assign.
    • app/scripts/controllers/metametrics-controller.ts: Rework #buildValidTraits to use for...of accumulation; preserve validation and return shape.
    • app/scripts/lib/ComposableObservableStore.js: Use Object.assign when merging child states in getFlatState.
  • Shared/Constants
    • shared/constants/tokens.js: Build STATIC_MAINNET_TOKEN_LIST via loop; switch to named export after declaration.
  • Selectors
    • shared/modules/selectors/networks.ts: Build clientIdsByChain via loop; in getNetworksByScopes, use concat instead 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
    • 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 update checkedChainIds via loops; rework "select all" toggle to build a new map.
  • Tests
    • test/e2e/fixture-builder.js: Build optionalScopes for multichain test dapp using a loop.

Written by Cursor Bugbot for commit 41a2b7f. This will update automatically on new commits. Configure here.

@n3ps n3ps requested review from a team as code owners October 31, 2025 18:31
@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-core-extension-ux Core Extension UX team label Oct 31, 2025
@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/core-extension-ux (1 files, +34 -32)
  • 📁 ui/
    • 📁 components/
      • 📁 multichain/
        • 📁 asset-picker-amount/
          • 📁 asset-picker-modal/
            • 📄 asset-picker-modal-network.tsx +34 -32

🧪 @MetaMask/qa (1 files, +10 -12)
  • 📁 test/
    • 📁 e2e/
      • 📄 fixture-builder.js +10 -12

@metamaskbot
Copy link
Collaborator

Builds ready [d33409b]
UI Startup Metrics (1218 ± 71 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1218110415297112621350
load103493212306310741142
domContentLoaded102792712216210671134
domInteractive211486132052
firstPaint63282127742410501140
backgroundConnect23121728510235248
firstReactRender29186283345
getState208102112335
initialActions61648720
loadScripts80268197562845907
setupStore1072841119
numNetworkReqs96327632
BrowserifyPower User HomeuiStartup22721864353658229213536
load1136934171827813981718
domContentLoaded1127929170727613921707
domInteractive291563185963
firstPaint61612516554999861655
backgroundConnect284226543101307543
firstReactRender27243842838
getState18314223022190230
initialActions121123296123
loadScripts879703141224210711412
setupStore1292841228
numNetworkReqs329187660179550660
WebpackStandard HomeuiStartup8207001083788261037
load60155387874603822
domContentLoaded59354785572595811
domInteractive15114661430
firstPaint19355890189197587
backgroundConnect24125182841
firstReactRender27175373133
getState1373041420
initialActions3011247
loadScripts59054484469592800
setupStore1052631215
numNetworkReqs96368832
WebpackPower User HomeuiStartup16531186274542621132745
load68056611621668201162
domContentLoaded64555610621367531062
domInteractive18123992839
firstPaint3256511783205781178
backgroundConnect13119509171352509
firstReactRender24212822528
getState16314527132159271
initialActions603611436
loadScripts64155410521337421052
setupStore19590212790
numNetworkReqs337201688178590688
FirefoxBrowserifyStandard HomeuiStartup1431124817229614981598
load1215108013846712591341
domContentLoaded1215108013836712591341
domInteractive1143627845120216
firstPaint------
backgroundConnect4324143214886
firstReactRender26215762639
getState84597718
initialActions3110238
loadScripts1187106313416512371304
setupStore136202191218
numNetworkReqs96337730
BrowserifyPower User HomeuiStartup25902181349640027053496
load13411148151110714151511
domContentLoaded13411148151110714151511
domInteractive1656833478217334
firstPaint------
backgroundConnect16834501164400501
firstReactRender40295594855
getState1327118335166183
initialActions71205820
loadScripts12981126147210013861472
setupStore3261293042129
numNetworkReqs25215345290334452
WebpackStandard HomeuiStartup15601405186710816061809
load1340118316388813911513
domContentLoaded1340118216388813901513
domInteractive1073243762111227
firstPaint------
backgroundConnect4423131195280
firstReactRender302275122870
getState8413313713
initialActions4148539
loadScripts1312116516218613651481
setupStore1274671128
numNetworkReqs96367730
WebpackPower User HomeuiStartup27652272360142429213601
load16091294229430117742294
domContentLoaded16081293229430117742294
domInteractive17785834177206834
firstPaint------
backgroundConnect15548562125167562
firstReactRender453294154994
getState1407525544159255
initialActions1411262911126
loadScripts15531273225527317362255
setupStore29664174064
numNetworkReqs24914849895341498
📊 Page Load Benchmark Results

Current Commit: d33409b | Date: 10/31/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±42ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 731ms (±37ms) 🟢 | historical mean value: 724ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±11ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 42ms 1.02s 1.34s 1.08s 1.34s
domContentLoaded 731ms 37ms 704ms 1.01s 756ms 1.01s
firstPaint 79ms 11ms 68ms 176ms 88ms 176ms
firstContentfulPaint 79ms 11ms 68ms 176ms 88ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 65 Bytes (0%)
  • ui: -26 Bytes (0%)
  • common: 10 Bytes (0%)

@metamaskbot
Copy link
Collaborator

Builds ready [41a2b7f]
UI Startup Metrics (1222 ± 68 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1222108913886812651360
load103791411945810761135
domContentLoaded103191111885810711127
domInteractive201476101845
firstPaint63083116741210501117
backgroundConnect2322192627234244
firstReactRender28185383543
getState23791122747
initialActions71869718
loadScripts80569596457844893
setupStore1163041118
numNetworkReqs96327630
BrowserifyPower User HomeuiStartup21861742387967729103879
load1111900193033515371930
domContentLoaded1098894187932815331879
domInteractive271473193873
firstPaint59219515714029191571
backgroundConnect265219650101259650
firstReactRender25223632636
getState18315531342175313
initialActions82329732
loadScripts861668149129712931491
setupStore1382551525
numNetworkReqs347211710202680710
WebpackStandard HomeuiStartup8046891067788221013
load59155086066586804
domContentLoaded58454585265580796
domInteractive15115381335
firstPaint19355851181185562
backgroundConnect21105482539
firstReactRender27176793147
getState1062841215
initialActions3021347
loadScripts58154384263577786
setupStore1043441116
numNetworkReqs96338832
WebpackPower User HomeuiStartup16961411240735722472407
load71758812322138571232
domContentLoaded67957110441688261044
domInteractive19134293142
firstPaint3826110483386021048
backgroundConnect13030446150303446
firstReactRender27233543135
getState15612721016160210
initialActions8129102229
loadScripts67456910341658141034
setupStore20757172857
numNetworkReqs317173571144544571
FirefoxBrowserifyStandard HomeuiStartup1397125418179714541546
load1192106515977812351305
domContentLoaded1192106515977812351305
domInteractive1153345260121251
firstPaint------
backgroundConnect372484104358
firstReactRender25205142533
getState64485610
initialActions3117235
loadScripts1171104915637712131284
setupStore145198201220
numNetworkReqs96337828
BrowserifyPower User HomeuiStartup27602253416158129474161
load14291256183916715591839
domContentLoaded14291256183916715581839
domInteractive1919737291286372
firstPaint------
backgroundConnect17739656185360656
firstReactRender38295684556
getState1277219928145199
initialActions2501674912167
loadScripts13791222177514914841775
setupStore4662596747259
numNetworkReqs269161576121349576
WebpackStandard HomeuiStartup16481433197511417081874
load14161220172710214761655
domContentLoaded14161220172710214751654
domInteractive1083932445118218
firstPaint------
backgroundConnect4923235265792
firstReactRender312383103142
getState9414115717
initialActions4054649
loadScripts1386120217089714401577
setupStore14780111349
numNetworkReqs96337827
WebpackPower User HomeuiStartup27402285394042829313940
load15471295178017617291780
domContentLoaded15461295178017617281780
domInteractive1226823553186235
firstPaint------
backgroundConnect17951666148259666
firstReactRender40295794957
getState1346822742171227
initialActions2312115024211
loadScripts15031267174616916761746
setupStore28783244183
numNetworkReqs26115651599334515
📊 Page Load Benchmark Results

Current Commit: 41a2b7f | Date: 10/31/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±40ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 726ms (±37ms) 🟢 | historical mean value: 723ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±10ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 40ms 1.02s 1.33s 1.07s 1.33s
domContentLoaded 726ms 37ms 706ms 1.00s 743ms 1.00s
firstPaint 78ms 10ms 60ms 164ms 88ms 164ms
firstContentfulPaint 78ms 10ms 60ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 114 Bytes (0%)
  • ui: -26 Bytes (0%)
  • common: 28 Bytes (0%)

@n3ps n3ps enabled auto-merge November 3, 2025 15:13
Copy link
Member

@seaona seaona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice change! LGMT

Copy link
Contributor

@vinnyhoward vinnyhoward left a 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

@n3ps n3ps added this pull request to the merge queue Nov 3, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 3, 2025
@n3ps n3ps added this pull request to the merge queue Nov 3, 2025
Merged via the queue into main with commit 28ff526 Nov 3, 2025
176 checks passed
@n3ps n3ps deleted the n3ps/accumulator-spread-perf branch November 3, 2025 23:31
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2025
@metamaskbot metamaskbot added the release-13.9.0 Issue or pull request that will be included in release 13.9.0 label Nov 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.9.0 Issue or pull request that will be included in release 13.9.0 size-M team-core-extension-ux Core Extension UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants