MCPcopy Index your code
hub / github.com/tidwall/sjson / parsePath

Function parsePath

sjson.go:54–112  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

52}
53
54func parsePath(path string) (res pathResult, simple bool) {
55 var r pathResult
56 if len(path) > 0 && path[0] == ':' {
57 r.force = true
58 path = path[1:]
59 }
60 for i := 0; i < len(path); i++ {
61 if path[i] == '.' {
62 r.part = path[:i]
63 r.gpart = path[:i]
64 r.path = path[i+1:]
65 r.more = true
66 return r, true
67 }
68 if !isSimpleChar(path[i]) {
69 return r, false
70 }
71 if path[i] == '\\' {
72 // go into escape mode. this is a slower path that
73 // strips off the escape character from the part.
74 epart := []byte(path[:i])
75 gpart := []byte(path[:i+1])
76 i++
77 if i < len(path) {
78 epart = append(epart, path[i])
79 gpart = append(gpart, path[i])
80 i++
81 for ; i < len(path); i++ {
82 if path[i] == '\\' {
83 gpart = append(gpart, '\\')
84 i++
85 if i < len(path) {
86 epart = append(epart, path[i])
87 gpart = append(gpart, path[i])
88 }
89 continue
90 } else if path[i] == '.' {
91 r.part = string(epart)
92 r.gpart = string(gpart)
93 r.path = path[i+1:]
94 r.more = true
95 return r, true
96 } else if !isSimpleChar(path[i]) {
97 return r, false
98 }
99 epart = append(epart, path[i])
100 gpart = append(gpart, path[i])
101 }
102 }
103 // append the last part
104 r.part = string(epart)
105 r.gpart = string(gpart)
106 return r, true
107 }
108 }
109 r.part = path
110 r.gpart = path
111 return r, true

Callers 1

setFunction · 0.85

Calls 1

isSimpleCharFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…