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

Method binaryAppendCall

gen/marshal.go:435–448  ·  view source on GitHub ↗

binaryAppendCall generates code for appender interfaces that use pre-allocated buffer. We optimize for cases where the size is 0-256 bytes.

(vname, method, appendFunc string)

Source from the content-addressed store, hash-verified

433// binaryAppendCall generates code for appender interfaces that use pre-allocated buffer.
434// We optimize for cases where the size is 0-256 bytes.
435func (m *marshalGen) binaryAppendCall(vname, method, appendFunc string) {
436 sz := randIdent()
437 vname = strings.Trim(vname, "(*)")
438 // Reserve 2 bytes for the header bin8 or str8.
439 m.p.printf("\no = append(o, 0, 0); %s := len(o)", sz)
440 m.p.printf("\no, err = %s.%s(o)", vname, method)
441 m.p.wrapErrCheck(m.ctx.ArgsStr())
442 m.p.printf("\n%s = len(o) - %s", sz, sz)
443 if appendFunc == "msgp.AppendString" {
444 m.p.printf("\no = msgp.AppendBytesStringTwoPrefixed(o, %s)", sz)
445 } else {
446 m.p.printf("\no = msgp.AppendBytesTwoPrefixed(o, %s)", sz)
447 }
448}

Callers 1

gBaseMethod · 0.95

Calls 4

randIdentFunction · 0.85
printfMethod · 0.80
wrapErrCheckMethod · 0.80
ArgsStrMethod · 0.80

Tested by

no test coverage detected