(c *recordCache, p []string)
| 134 | } |
| 135 | |
| 136 | func (r *record) addPath(c *recordCache, p []string) (removed int) { |
| 137 | if len(p) == 0 { |
| 138 | return 0 |
| 139 | } |
| 140 | at := len(r.fields) - 1 |
| 141 | if len(r.fields) == 0 || r.fields[at].Name != p[0] { |
| 142 | r.fields = append(r.fields, super.NewField(p[0], nil)) |
| 143 | var rec *record |
| 144 | if len(p) > 1 { |
| 145 | rec = c.new() |
| 146 | } |
| 147 | r.records = append(r.records, rec) |
| 148 | } else if len(p) == 1 || r.records[at] == nil { |
| 149 | // If this isn't a new field and we're either at a leaf or the |
| 150 | // previously value was a leaf, we're stacking on a previously created |
| 151 | // record and need to signal that values have been removed. |
| 152 | removed = r.records[at].countLeaves() |
| 153 | if len(p) > 1 { |
| 154 | r.records[at] = c.new() |
| 155 | } else { |
| 156 | r.records[at] = nil |
| 157 | } |
| 158 | } |
| 159 | return removed + r.records[len(r.records)-1].addPath(c, p[1:]) |
| 160 | } |
| 161 | |
| 162 | func (r *record) countLeaves() int { |
| 163 | if r == nil { |
no test coverage detected