Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Reduce contract code size by wrapping clamping of args into a loop #1488
What I did
Reduced contract code size due to codegen of run-time type checking of list elements.
How I did it
All the tests pass.
How to verify it
Compile the following contract.
struct Animal: Name: uint256 Exists: int128 COLLECTION_SIZE: constant(uint256) = 1000 contractOwner: address daddy: address collection: map(address, Animal) count: int128 @private @constant def isZookeeper(sender: address) -> bool: return sender == self.contractOwner or sender == self.daddy @public def addToCollection(animals: address[COLLECTION_SIZE]): assert self.isZookeeper(msg.sender) for animal in animals: if animal == ZERO_ADDRESS: break if self.collection[animal].Exists == 0: self.count += 1 self.collection[animal].Exists = self.count @public def __init__(myDaddy: address): self.daddy = myDaddy
Old code size (bytes): 55340
Cute Animal Picture