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

Function readIntfBytesDepth

msgp/read_bytes.go:1199–1307  ·  view source on GitHub ↗
(b []byte, depth int)

Source from the content-addressed store, hash-verified

1197}
1198
1199func readIntfBytesDepth(b []byte, depth int) (i any, o []byte, err error) {
1200 if depth >= recursionLimit {
1201 err = ErrRecursion
1202 return
1203 }
1204 if len(b) < 1 {
1205 err = ErrShortBytes
1206 return
1207 }
1208
1209 k := NextType(b)
1210
1211 switch k {
1212 case MapType:
1213 i, o, err = readMapStrIntfBytesDepth(b, nil, depth+1)
1214 return
1215
1216 case ArrayType:
1217 var sz uint32
1218 sz, o, err = ReadArrayHeaderBytes(b)
1219 if err != nil {
1220 return
1221 }
1222 // Each element will at least be 1 byte.
1223 if uint32(len(o)) < sz {
1224 err = ErrShortBytes
1225 return
1226 }
1227 j := make([]any, int(sz))
1228 i = j
1229 for d := range j {
1230 j[d], o, err = readIntfBytesDepth(o, depth+1)
1231 if err != nil {
1232 return
1233 }
1234 }
1235 return
1236
1237 case Float32Type:
1238 i, o, err = ReadFloat32Bytes(b)
1239 return
1240
1241 case Float64Type:
1242 i, o, err = ReadFloat64Bytes(b)
1243 return
1244
1245 case IntType:
1246 i, o, err = ReadInt64Bytes(b)
1247 return
1248
1249 case UintType:
1250 i, o, err = ReadUint64Bytes(b)
1251 return
1252
1253 case BoolType:
1254 i, o, err = ReadBoolBytes(b)
1255 return
1256

Callers 2

readMapStrIntfBytesDepthFunction · 0.85
ReadIntfBytesFunction · 0.85

Calls 15

NextTypeFunction · 0.85
readMapStrIntfBytesDepthFunction · 0.85
ReadArrayHeaderBytesFunction · 0.85
ReadFloat32BytesFunction · 0.85
ReadFloat64BytesFunction · 0.85
ReadInt64BytesFunction · 0.85
ReadUint64BytesFunction · 0.85
ReadBoolBytesFunction · 0.85
ReadTimeBytesFunction · 0.85
ReadComplex64BytesFunction · 0.85
ReadComplex128BytesFunction · 0.85
peekExtensionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…