From f2ba02b77978d2fb5030483056f1939027fd1abc Mon Sep 17 00:00:00 2001 From: Alexander Staubo Date: Thu, 28 Apr 2022 11:18:10 +0200 Subject: [PATCH] fix: don't cache array/slice length when traversing. --- pointers.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pointers.go b/pointers.go index d5b92bc..74b9a0f 100644 --- a/pointers.go +++ b/pointers.go @@ -118,8 +118,7 @@ func (pv *pointerVisitor) consider(v reflect.Value) { // Now descend into any children of this value switch v.Kind() { case reflect.Slice, reflect.Array: - numEntries := v.Len() - for i := 0; i < numEntries; i++ { + for i := 0; i < v.Len(); i++ { pv.consider(v.Index(i)) }