Gas optimizations in Ownable and Secondary contracts #1905 (#1910)

This commit is contained in:
Igor Sobolev
2019-09-10 00:47:05 +03:00
committed by Francisco Giordano
parent 52dc14c368
commit 6f8e672f3f
2 changed files with 7 additions and 5 deletions

View File

@ -19,8 +19,9 @@ contract Ownable is Context {
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
_owner = _msgSender();
emit OwnershipTransferred(address(0), _owner);
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**

View File

@ -18,8 +18,9 @@ contract Secondary is Context {
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor () internal {
_primary = _msgSender();
emit PrimaryTransferred(_primary);
address msgSender = _msgSender();
_primary = msgSender;
emit PrimaryTransferred(msgSender);
}
/**
@ -44,6 +45,6 @@ contract Secondary is Context {
function transferPrimary(address recipient) public onlyPrimary {
require(recipient != address(0), "Secondary: new primary is the zero address");
_primary = recipient;
emit PrimaryTransferred(_primary);
emit PrimaryTransferred(recipient);
}
}