Skip to content

Commit 6f8e672

Browse files
sobolev-igorfrangio
authored andcommitted
Gas optimizations in Ownable and Secondary contracts #1905 (#1910)
1 parent 52dc14c commit 6f8e672

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

contracts/ownership/Ownable.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ contract Ownable is Context {
1919
* @dev Initializes the contract setting the deployer as the initial owner.
2020
*/
2121
constructor () internal {
22-
_owner = _msgSender();
23-
emit OwnershipTransferred(address(0), _owner);
22+
address msgSender = _msgSender();
23+
_owner = msgSender;
24+
emit OwnershipTransferred(address(0), msgSender);
2425
}
2526

2627
/**

contracts/ownership/Secondary.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ contract Secondary is Context {
1818
* @dev Sets the primary account to the one that is creating the Secondary contract.
1919
*/
2020
constructor () internal {
21-
_primary = _msgSender();
22-
emit PrimaryTransferred(_primary);
21+
address msgSender = _msgSender();
22+
_primary = msgSender;
23+
emit PrimaryTransferred(msgSender);
2324
}
2425

2526
/**
@@ -44,6 +45,6 @@ contract Secondary is Context {
4445
function transferPrimary(address recipient) public onlyPrimary {
4546
require(recipient != address(0), "Secondary: new primary is the zero address");
4647
_primary = recipient;
47-
emit PrimaryTransferred(_primary);
48+
emit PrimaryTransferred(recipient);
4849
}
4950
}

0 commit comments

Comments
 (0)