MCPcopy
hub / github.com/tinylib/msgp / assignArray

Method assignArray

gen/decode.go:78–109  ·  view source on GitHub ↗
(name string, typ string, fieldLimit uint32)

Source from the content-addressed store, hash-verified

76}
77
78func (d *decodeGen) assignArray(name string, typ string, fieldLimit uint32) {
79 if !d.p.ok() {
80 return
81 }
82 d.p.printf("\n%s, err = dc.Read%s()", name, typ)
83 d.p.wrapErrCheck(d.ctx.ArgsStr())
84
85 // Determine effective limit: field limit > context field limit > file limit
86 var limit uint32
87 var limitName string
88
89 if fieldLimit > 0 {
90 // Explicit field limit passed as parameter
91 limit = fieldLimit
92 limitName = fmt.Sprintf("%d", fieldLimit)
93 } else if d.ctx.currentFieldArrayLimit != math.MaxUint32 {
94 // Field limit from context (set during field processing)
95 limit = d.ctx.currentFieldArrayLimit
96 limitName = fmt.Sprintf("%d", d.ctx.currentFieldArrayLimit)
97 } else if d.ctx.arrayLimit != math.MaxUint32 {
98 // File-level limit
99 limit = d.ctx.arrayLimit
100 limitName = fmt.Sprintf("%slimitArrays", d.ctx.limitPrefix)
101 }
102
103 if limit > 0 && limit != math.MaxUint32 {
104 d.p.printf("\nif %s > %s {", name, limitName)
105 d.p.printf("\nerr = msgp.ErrLimitExceeded")
106 d.p.printf("\nreturn")
107 d.p.printf("\n}")
108 }
109}
110
111func (d *decodeGen) assignMap(name string, typ string, fieldLimit uint32) {
112 if !d.p.ok() {

Callers 2

structAsTupleMethod · 0.95
gSliceMethod · 0.95

Calls 4

okMethod · 0.80
printfMethod · 0.80
wrapErrCheckMethod · 0.80
ArgsStrMethod · 0.80

Tested by

no test coverage detected