update maps the object into the receiver's vals slice while also seeing if we can reuse the cached record type. If not we look up a new type, cache it, and save the field for the cache check.
(rec map[string]fieldValue)
| 211 | // seeing if we can reuse the cached record type. If not we look up |
| 212 | // a new type, cache it, and save the field for the cache check. |
| 213 | func (r *recordSpreadExpr) update(rec map[string]fieldValue) { |
| 214 | if len(r.fields) != len(rec) { |
| 215 | r.invalidate(rec) |
| 216 | return |
| 217 | } |
| 218 | for name, fv := range rec { |
| 219 | typ := fv.none |
| 220 | if typ == nil { |
| 221 | typ = fv.value.Type() |
| 222 | } |
| 223 | if r.fields[fv.index] != super.NewFieldWithOpt(name, typ, fv.opt) { |
| 224 | r.invalidate(rec) |
| 225 | return |
| 226 | } |
| 227 | r.vals[fv.index] = fv |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | func (r *recordSpreadExpr) invalidate(rec map[string]fieldValue) { |
| 232 | n := len(rec) |
no test coverage detected