You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
if (_condition.method == EvaluationMethod.SpecificToken) {
// How many times has this token id been used to commit to offers in the group?uint256 commitCount = lookups.conditionalCommitsByTokenId[_tokenId][_groupId];
require(commitCount < _condition.maxCommits, MAX_COMMITS_TOKEN_REACHED);
allow =holdsSpecificToken(_buyer, _condition, _tokenId);
if (allow) {
// Increment number of commits to the group for this token id if they are allowed to commit
lookups.conditionalCommitsByTokenId[_tokenId][_groupId] =++commitCount;
}
} elseif (_condition.method == EvaluationMethod.Threshold) {
// How many times has this address committed to offers in the group?uint256 commitCount = lookups.conditionalCommitsByAddress[_buyer][_groupId];
require(commitCount < _condition.maxCommits, MAX_COMMITS_ADDRESS_REACHED);
allow =holdsThreshold(_buyer, _condition, _tokenId);
if (allow) {
// Increment number of commits to the group for this address if they are allowed to commit
lookups.conditionalCommitsByAddress[_buyer][_groupId] =++commitCount;
}
} else {
Recommendation:
As the lookups internally perform an expensive keccak256 operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping in case of primitive types or holds a storage pointer to the struct contained.
The text was updated successfully, but these errors were encountered:
EHF-01C: Inefficient
mapping
LookupsDescription:
The linked statements perform key-based lookup operations on
mapping
declarations from storage multiple times for the same key redundantly.Example:
Recommendation:
As the lookups internally perform an expensive
keccak256
operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of themapping
in case of primitive types or holds astorage
pointer to thestruct
contained.The text was updated successfully, but these errors were encountered: