SetReadObject sets the id for an object that has been read. id: The id from #NextReadRefId. object: the object that has been read
(refId int32, value reflect.Value)
| 291 | // id: The id from {@link #NextReadRefId}. |
| 292 | // object: the object that has been read |
| 293 | func (r *RefResolver) SetReadObject(refId int32, value reflect.Value) { |
| 294 | if !r.refTracking { |
| 295 | return |
| 296 | } |
| 297 | if refId >= 0 { |
| 298 | r.readObjects[refId] = value |
| 299 | // Consume the preserved ref id if it's the most recent. |
| 300 | // This keeps the readRefIds stack in sync for serializers that |
| 301 | // set the object directly instead of calling Reference(). |
| 302 | if n := len(r.readRefIds); n > 0 && r.readRefIds[n-1] == refId { |
| 303 | r.readRefIds = r.readRefIds[:n-1] |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | func (r *RefResolver) reset() { |
| 309 | r.resetRead() |
no outgoing calls