Clarity and logic optimizations in `DistributionManager`
LHerskind opened this issue · comments
The current DistributionManager
have some low-hanging fruits in terms of clarity and logic optimizations.
Storage usage:
- The current
AssetData
uses only104
bits for theindex
with the word having8
bits unused, as we are normally using128
bits for these values, I suggest that we use the extra8
bits to move closer to the normal index range.
Clarity:
- The
users
mapping holds the indexes for each user, and it would be more clear if the naming showed this, suggesting that we rename it touserIndexes
.
Logic / Gas optimizations:
emissionPerSecond
is fetched at every call to_updateAssetStateInternal
but is not used whenblock.timestamp == lastUpdateTimestamp
, the fetching could be moved below this point to remove unnecessary reads.- In
_updateAssetStateInternal
the valueassetConfig.lastUpdateTimestamp
is updated in both branches of the if-else, so it may just be moved out in full, this would also allow us to remove the else case entirely.