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

Method UnmarshalMsg

msgp/setof/generated.go:234–260  ·  view source on GitHub ↗

UnmarshalMsg decodes the message from the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

232
233// UnmarshalMsg decodes the message from the bytes.
234func (s *StringSorted) UnmarshalMsg(bytes []byte) ([]byte, error) {
235 if msgp.IsNil(bytes) {
236 *s = nil
237 return bytes[msgp.NilSize:], nil
238 }
239 // Read the array header
240 sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
241 if err != nil {
242 return nil, err
243 }
244 dst := *s
245 if dst == nil {
246 dst = make(StringSorted, sz)
247 } else {
248 clear(dst)
249 }
250 for range sz {
251 var k string
252 k, bytes, err = msgp.ReadStringBytes(bytes)
253 if err != nil {
254 return nil, err
255 }
256 dst[string(k)] = struct{}{}
257 }
258 *s = dst
259 return bytes, nil
260}
261
262// Msgsize returns the maximum size of the message.
263func (s StringSorted) Msgsize() int {

Calls 3

IsNilFunction · 0.92
ReadArrayHeaderBytesFunction · 0.92
ReadStringBytesFunction · 0.92