MCPcopy
hub / github.com/bnb-chain/bsc / generate

Method generate

rlp/typecache.go:83–105  ·  view source on GitHub ↗
(typ reflect.Type, tags rlpstruct.Tags)

Source from the content-addressed store, hash-verified

81}
82
83func (c *typeCache) generate(typ reflect.Type, tags rlpstruct.Tags) *typeinfo {
84 c.mu.Lock()
85 defer c.mu.Unlock()
86
87 cur := c.cur.Load().(map[typekey]*typeinfo)
88 if info := cur[typekey{typ, tags}]; info != nil {
89 return info
90 }
91
92 // Copy cur to next.
93 c.next = make(map[typekey]*typeinfo, len(cur)+1)
94 for k, v := range cur {
95 c.next[k] = v
96 }
97
98 // Generate.
99 info := c.infoWhileGenerating(typ, tags)
100
101 // next -> cur
102 c.cur.Store(c.next)
103 c.next = nil
104 return info
105}
106
107func (c *typeCache) infoWhileGenerating(typ reflect.Type, tags rlpstruct.Tags) *typeinfo {
108 key := typekey{typ, tags}

Callers 1

infoMethod · 0.95

Calls 5

infoWhileGeneratingMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.45
LoadMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected