Conversation
…s an object Adds `Object.values` operation for deriving ComposableController input array
|
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. |
|
2c34547 to
8774483
Compare
|
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12374 +/- ##
==========================================
+ Coverage 56.41% 56.46% +0.04%
==========================================
Files 1797 1808 +11
Lines 40586 40724 +138
Branches 5097 5131 +34
==========================================
+ Hits 22896 22993 +97
- Misses 16134 16159 +25
- Partials 1556 1572 +16 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
|
tommasini
left a comment
There was a problem hiding this comment.
LOVE IT! LGTM! So cool that we now only have base controllers v2 controllers!
tommasini
left a comment
There was a problem hiding this comment.
LOVE IT! LGTM! So cool that we now only have base controllers v2 controllers!



Overview
Optimizes an expensive operation from the Engine initialization process.
A custom span for measuring this process was added in #11579.
Motivation
Currently, the Engine's context object is created using a
Array.prototype.reduce()operation on a largecontrollersarray. This reduce call is also written to create a temporary object on every iteration.Benchmarks show that this particular implementation of reduce runs significantly slower than other means of creating an object, and compared to reduce calls that are written to re-use the output object the difference is in four orders of magnitude (1555.6 Ops/sec vs. 0.2 Ops/sec).
A simple fix would be to refactor the reduce operation so it doesn't rely on temporary objects and spreading:
However, we can also avoid the cost of running reduce altogether simply by creating a controller name-keyed object to assign to the Engine's context field. This is also the approach taken in the Extension
MetamaskController.Description
controllersarray in the Engine class with a corresponding object that is directly assigned tocontext.Object.valuesfor deriving ComposableController input withObject.keysandreduce(re-uses object).Related issues
Manual testing steps
Screenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist