Created
April 24, 2017 16:01
-
-
Save raineorshine/5816c7f647e0090fc3ac52b9d036bb99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract MyContract { | |
User user; | |
mapping (address => User) public users; | |
uint40 time; // cast to 5 bytes - packed with user | |
address addr1; // 20 bytes - packed with time | |
address addr2; // 20 bytes - unpacked, one slot | |
struct User { | |
uint40 time; // cast to 5 bytes - packed with user | |
address addr1; // 20 bytes - packed with time | |
address addr2; // 20 bytes - unpacked, one slot | |
} | |
// 45510 / 15510 | |
function setVars() { | |
time = uint40(now); | |
addr1 = this; | |
addr2 = this; | |
} | |
// 45616 / 15616 | |
function setUser() { | |
user = User({ | |
time: uint40(now), | |
addr1: this, | |
addr2: this | |
}); | |
} | |
// 45727 / 15727 | |
function setUserMapping() { | |
users[this] = User({ | |
time: uint40(now), | |
addr1: this, | |
addr2: this | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment