diff options
author | chriseth <c@ethdev.com> | 2016-12-12 00:51:17 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-12-12 00:57:15 +0800 |
commit | bfa4f451160bff14d79bf6e25d969b1f586a8b00 (patch) | |
tree | dd16eb515fd3c1594a044d1ec7235782ef6ffa36 /libsolidity/codegen/ArrayUtils.cpp | |
parent | 4184525d4ad7aff3acb2d521c3cdc21054e36eff (diff) | |
download | dexon-solidity-bfa4f451160bff14d79bf6e25d969b1f586a8b00.tar.gz dexon-solidity-bfa4f451160bff14d79bf6e25d969b1f586a8b00.tar.zst dexon-solidity-bfa4f451160bff14d79bf6e25d969b1f586a8b00.zip |
Split memcopy into three functions.
Diffstat (limited to 'libsolidity/codegen/ArrayUtils.cpp')
-rw-r--r-- | libsolidity/codegen/ArrayUtils.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 2c982982..352c7177 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -335,9 +335,14 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord if (baseSize > 1) m_context << u256(baseSize) << Instruction::MUL; // stack: <target> <source> <size> - //@TODO do not use ::CALL if less than 32 bytes? m_context << Instruction::DUP1 << Instruction::DUP4 << Instruction::DUP4; - utils.memoryCopy(); + // We can resort to copying full 32 bytes only if + // - the length is known to be a multiple of 32 or + // - we will pad to full 32 bytes later anyway. + if (((baseSize % 32) == 0) || _padToWordBoundaries) + utils.memoryCopy32(); + else + utils.memoryCopy(); m_context << Instruction::SWAP1 << Instruction::POP; // stack: <target> <size> |