mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol->Yul] Adding util function to copy literal to storage.
Co-authored-by: Daniel Kirchner <daniel@ekpyron.org> Co-authored-by: chriseth <chris@ethereum.org>
This commit is contained in:
co-authored by
Daniel Kirchner
chriseth
parent
9d156b52c4
commit
f0c5cdca9f
@@ -4,12 +4,17 @@ contract C {
|
||||
|
||||
function f() public {
|
||||
a.push("abc");
|
||||
a.push("def");
|
||||
a.push("abcdefghabcdefghabcdefghabcdefgh");
|
||||
a.push("abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh");
|
||||
assert(a[0][0] == "a");
|
||||
assert(a[1][0] == "d");
|
||||
assert(a[1][31] == "h");
|
||||
assert(a[2][32] == "a");
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() ->
|
||||
// gas irOptimized: 181480
|
||||
// gas legacy: 180320
|
||||
// gas legacyOptimized: 180103
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
bytes public s = "abc";
|
||||
bytes public s1 = "abcd";
|
||||
function f() public {
|
||||
s = "abcd";
|
||||
s1 = "abc";
|
||||
}
|
||||
function g() public {
|
||||
(s, s1) = ("abc", "abcd");
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// s() -> 0x20, 3, "abc"
|
||||
// s1() -> 0x20, 4, "abcd"
|
||||
// f() ->
|
||||
// s() -> 0x20, 4, "abcd"
|
||||
// s1() -> 0x20, 3, "abc"
|
||||
// g() ->
|
||||
// s() -> 0x20, 3, "abc"
|
||||
// s1() -> 0x20, 4, "abcd"
|
||||
Reference in New Issue
Block a user