Merge pull request #3697 from ethereum/fixAvoidStorageClearLoop

Properly skip cleanup if only enlarging storage array.
This commit is contained in:
Alex Beregszaszi 2018-03-12 14:08:24 +01:00 committed by GitHub
commit c6e9dd13bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ Features:
Bugfixes:
* Code Generator: Properly skip unneeded storgae array cleanup when not reducing length.

View File

@ -741,10 +741,10 @@ void ArrayUtils::resizeDynamicArray(ArrayType const& _typeIn) const
if (_type.isByteArray())
// For a "long" byte array, store length as 2*length+1
_context << Instruction::DUP1 << Instruction::ADD << u256(1) << Instruction::ADD;
_context<< Instruction::DUP4 << Instruction::SSTORE;
_context << Instruction::DUP4 << Instruction::SSTORE;
// skip if size is not reduced
_context << Instruction::DUP2 << Instruction::DUP2
<< Instruction::ISZERO << Instruction::GT;
<< Instruction::GT << Instruction::ISZERO;
_context.appendConditionalJumpTo(resizeEnd);
// size reduced, clear the end of the array