aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-04-14 06:17:56 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:18 +0800
commit80d06d358a171daf7a260656c33d08fac1868382 (patch)
treecc3968444137d0b2784b8bd5edd41fa502db7084 /packages
parent1cace49b744f216f0558880a80675463737f6a12 (diff)
downloaddexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.tar
dexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.tar.gz
dexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.tar.bz2
dexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.tar.lz
dexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.tar.xz
dexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.tar.zst
dexon-sol-tools-80d06d358a171daf7a260656c33d08fac1868382.zip
Unrolled the loop that copies the Order struct in FillOrderNoThrow. Saves 900 gas
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol22
1 files changed, 17 insertions, 5 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
index 24bf78322..8ac9977bd 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
@@ -145,11 +145,23 @@ contract MixinWrapperFunctions is
paramsAreaOffset := add(paramsAreaOffset, 0x20)
// Write values for each field in the order
- for{let i := 0} lt(i, 13) {i := add(i, 1)} {
- mstore(dataAreaEnd, mload(sourceOffset))
- dataAreaEnd := add(dataAreaEnd, 0x20)
- sourceOffset := add(sourceOffset, 0x20)
- }
+ // It would be nice to use a loop, but we save on gas by writing
+ // the stores sequentially.
+ mstore(dataAreaEnd, mload(sourceOffset)) // makerAddress
+ mstore(add(dataAreaEnd, 0x20), mload(add(sourceOffset, 0x20))) // takerAddress
+ mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40))) // makerTokenAddress
+ mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60))) // takerTokenAddress
+ mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80))) // feeRecipientAddress
+ mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0))) // makerTokenAmount
+ mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0))) // takerTokenAmount
+ mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0))) // makerFeeAmount
+ mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100))) // takerFeeAmount
+ mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120))) // expirationTimeSeconds
+ mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140))) // salt
+ mstore(add(dataAreaEnd, 0x160), mload(add(sourceOffset, 0x160))) // Offset to makerAssetProxyMetadata
+ mstore(add(dataAreaEnd, 0x180), mload(add(sourceOffset, 0x180))) // Offset to takerAssetProxyMetadata
+ dataAreaEnd := add(dataAreaEnd, 0x1A0)
+ sourceOffset := add(sourceOffset, 0x1A0)
// Write offset to <order.makerAssetProxyMetadata>
mstore(add(dataAreaStart, mul(11, 0x20)), sub(dataAreaEnd, dataAreaStart))