NLA-01C: Inefficient mapping Lookups
Description:
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
bytes32 payloadHash = $.failedMessages[srcChainId][srcAddress][nonce];
require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message");
require(keccak256(payload) == payloadHash, "NonblockingLzApp: invalid payload");
// clear the stored message
$.failedMessages[srcChainId][srcAddress][nonce] = bytes32(0);
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.
NLA-01C: Inefficient
mappingLookupsDescription:
The linked statements perform key-based lookup operations on
mappingdeclarations from storage multiple times for the same key redundantly.Example:
Recommendation:
As the lookups internally perform an expensive
keccak256operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of themappingin case of primitive types or holds astoragepointer to thestructcontained.