-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Closed
Milestone
Description
This PR refers to the next-v5.0 branch. In #3876 two potential optimizations were identified.
_asSingletonArray: Throughout the contract we use:
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);We could combine this into a single function _asSigletonArrays(id, amount) and using assembly we would be able to do a single allocation and possibly avoid a couple of bounds checks.
_unsafeAccess: In places where we loop over arrays of ids and amounts, we don't need to do bounds checking inside the for loop, so we could define a function to skip it.
Given that these are arrays in memory, it's unclear how much of an improvement these optimizations will make, so we have to benchmark to know for sure.
Based on the results of using _unsafeAccess for memory arrays we should consider applying it in other places
Metadata
Metadata
Assignees
Labels
No labels