Distinguish finite slice views from cycles
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user