MCPcopy Index your code
hub / github.com/segmentio/encoding / decodeString

Method decodeString

json/decode.go:284–304  ·  view source on GitHub ↗
(b []byte, p unsafe.Pointer)

Source from the content-addressed store, hash-verified

282}
283
284func (d decoder) decodeString(b []byte, p unsafe.Pointer) ([]byte, error) {
285 if hasNullPrefix(b) {
286 return b[4:], nil
287 }
288
289 s, r, new, err := d.parseStringUnquote(b, nil)
290 if err != nil {
291 if len(b) == 0 || b[0] != '"' {
292 return d.inputError(b, stringType)
293 }
294 return r, err
295 }
296
297 if new || (d.flags&DontCopyString) != 0 {
298 *(*string)(p) = *(*string)(unsafe.Pointer(&s))
299 } else {
300 *(*string)(p) = string(s)
301 }
302
303 return r, nil
304}
305
306func (d decoder) decodeFromString(b []byte, p unsafe.Pointer, decode decodeFunc) ([]byte, error) {
307 if hasNullPrefix(b) {

Callers 7

decodeMapStringStringMethod · 0.95
decodeMapStringBoolMethod · 0.95
decodeInterfaceMethod · 0.95
AppendUnescapeFunction · 0.95

Calls 3

parseStringUnquoteMethod · 0.95
inputErrorMethod · 0.95
hasNullPrefixFunction · 0.85

Tested by

no test coverage detected