From 6f8e672f3fcb93289fb559ecbef72b8fd1cd56e1 Mon Sep 17 00:00:00 2001 From: Igor Sobolev <44194758+sobolev-igor@users.noreply.github.com> Date: Tue, 10 Sep 2019 00:47:05 +0300 Subject: [PATCH] Gas optimizations in Ownable and Secondary contracts #1905 (#1910) --- contracts/ownership/Ownable.sol | 5 +++-- contracts/ownership/Secondary.sol | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index a1a84931b..cd9c061d0 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -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); } /** diff --git a/contracts/ownership/Secondary.sol b/contracts/ownership/Secondary.sol index 5cb1dda05..cc474d43e 100644 --- a/contracts/ownership/Secondary.sol +++ b/contracts/ownership/Secondary.sol @@ -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); } }