@@ -19,9 +19,9 @@ func newTransientStorage() transientStorage {
1919// Set sets the transient-storage `value` for `key` at the given `addr`.
2020func (t transientStorage ) Set (addr common.Address , key , value common.Hash ) {
2121 if value == (common.Hash {}) { // this is a 'delete'
22- if _ , ok := t [addr ]; ok {
23- delete (t [ addr ] , key )
24- if len (t [ addr ] ) == 0 {
22+ if storage , ok := t [addr ]; ok {
23+ delete (storage , key )
24+ if len (storage ) == 0 {
2525 delete (t , addr )
2626 }
2727 }
@@ -35,11 +35,10 @@ func (t transientStorage) Set(addr common.Address, key, value common.Hash) {
3535
3636// Get gets the transient storage for `key` at the given `addr`.
3737func (t transientStorage ) Get (addr common.Address , key common.Hash ) common.Hash {
38- val , ok := t [addr ]
39- if ! ok {
40- return common.Hash {}
38+ if val , ok := t [addr ]; ok {
39+ return val [key ]
4140 }
42- return val [ key ]
41+ return common. Hash {}
4342}
4443
4544// Copy does a deep copy of the transientStorage
@@ -54,16 +53,16 @@ func (t transientStorage) Copy() transientStorage {
5453// PrettyPrint prints the contents of the access list in a human-readable form
5554func (t transientStorage ) PrettyPrint () string {
5655 out := new (strings.Builder )
57- var sortedAddrs []common.Address
56+ sortedAddrs := make ( []common.Address , 0 , len ( t ))
5857 for addr := range t {
5958 sortedAddrs = append (sortedAddrs , addr )
60- slices .SortFunc (sortedAddrs , common .Address .Cmp )
6159 }
60+ slices .SortFunc (sortedAddrs , common .Address .Cmp )
6261
6362 for _ , addr := range sortedAddrs {
6463 fmt .Fprintf (out , "%#x:" , addr )
65- var sortedKeys []common.Hash
6664 storage := t [addr ]
65+ sortedKeys := make ([]common.Hash , 0 , len (storage ))
6766 for key := range storage {
6867 sortedKeys = append (sortedKeys , key )
6968 }
0 commit comments