Storage storage s = getStorage();
LibDiamond.enforceIsContractOwner();
s.nxtpTxManager = _txMgrAddr;
}
Storage storage s = getStorage(); reads from storage even though the function can revert at LibDiamond.enforceIsContractOwner(); causing unnecessary usage of gas.
Recommend implementing LibDiamond.enforceIsContractOwner(); prior to Storage storage s = getStorage();
Example:
LibDiamond.enforceIsContractOwner();
Storage storage s = getStorage();
s.nxtpTxManager = _txMgrAddr;
}
Gas#2: Unnecessary else statement in swapAndStartBridgeTokensViaCBridge
The use of the else statement below is not necessary and can be avoided by implementing swapAndStartBridgeTokensViaCBridge in the same manner swapAndStartBridgeTokensViaHop or swapAndStartBridgeTokensViaNXTP have been implemented. Reference for swapAndStartBridgeTokensViaHop below.
Gas#1: Unecessary read from storage prior to a possible revert in
initNXTP
.L33-37
Storage storage s = getStorage();
reads from storage even though the function can revert atLibDiamond.enforceIsContractOwner();
causing unnecessary usage of gas.Recommend implementing
LibDiamond.enforceIsContractOwner();
prior toStorage storage s = getStorage();
Example:
Gas#2: Unnecessary
else
statement inswapAndStartBridgeTokensViaCBridge
L92-119
The use of the
else
statement below is not necessary and can be avoided by implementingswapAndStartBridgeTokensViaCBridge
in the same mannerswapAndStartBridgeTokensViaHop
orswapAndStartBridgeTokensViaNXTP
have been implemented. Reference forswapAndStartBridgeTokensViaHop
below.swapAndStartBridgeTokensViaCBridge
:swapAndStartBridgeTokensViaHop
swapAndStartBridgeTokensViaHop
:Note: Same issue present in
AnyswapFacet.swapAndStartBridgeTokensViaAnyswap
L74-108