Merge pull request #8179 from pinkiebell/codegen

libsolidity/codegen: Use calldatacopy to cheaply zero memory..
This commit is contained in:
chriseth 2020-01-28 18:07:30 +01:00 committed by GitHub
commit 35820398c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -605,7 +605,7 @@ void CompilerUtils::zeroInitialiseMemoryArray(ArrayType const& _type)
Whiskers templ(R"({
let size := mul(length, <element_size>)
// cheap way of zero-initializing a memory range
codecopy(memptr, codesize(), size)
calldatacopy(memptr, calldatasize(), size)
memptr := add(memptr, size)
})");
templ("element_size", to_string(_type.memoryStride()));

View File

@ -10131,7 +10131,7 @@ BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length)
BOOST_AUTO_TEST_CASE(correctly_initialize_memory_array_in_constructor)
{
// Memory arrays are initialized using codecopy past the size of the code.
// Memory arrays are initialized using calldatacopy past the size of the calldata.
// This test checks that it also works in the constructor context.
char const* sourceCode = R"(
contract C {