Distinguish finite slice views from cycles

This commit is contained in:
2026-10-25 21:22:01 +00:00
parent deb9aa5c69
commit ae3408a096
3 changed files with 86 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ type valueVisit struct {
typeOf reflect.Type
kind reflect.Kind
ptr uintptr
length int
}
// valueOperation owns one traversal's cycle and budget state and reuses the
@@ -107,6 +108,9 @@ func visitFor(value reflect.Value) (valueVisit, bool) {
return valueVisit{}, false
}
visit.ptr = value.Pointer()
if value.Kind() == reflect.Slice {
visit.length = value.Len()
}
case reflect.Map:
if value.Len() == 0 {
return valueVisit{}, false