From 9eb9117ba48a19b322e620522c9de31a6a2cd45d Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 30 Aug 2024 14:46:26 +0200 Subject: [PATCH] fix castSlice --- binary/slice.go | 3 +-- modeler/read_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/binary/slice.go b/binary/slice.go index 398dc7a..7a1dd4f 100644 --- a/binary/slice.go +++ b/binary/slice.go @@ -18,7 +18,7 @@ func reslice[T any](v []byte, length, rem int) []T { if rem > 0 { return append(s, make([]T, rem)...) } - return s[:length] + return s } func castSlice(c gltf.ComponentType, t gltf.AccessorType, count int, v []byte) any { @@ -27,7 +27,6 @@ func castSlice(c gltf.ComponentType, t gltf.AccessorType, count int, v []byte) a if count < l { l = count } else if count > l { - l = count rem = count - l } diff --git a/modeler/read_test.go b/modeler/read_test.go index 79f7de7..ae4e649 100644 --- a/modeler/read_test.go +++ b/modeler/read_test.go @@ -216,10 +216,10 @@ func TestReadAccessorAllocs(t *testing.T) { }) t.Run("2", func(t *testing.T) { buf := make([]byte, 24) - testFunc(t, buf, 1) - testFunc(t, buf, 1) - testFunc(t, buf, 1) - testFunc(t, buf, 1) + testFunc(t, buf, 3) + testFunc(t, buf, 3) + testFunc(t, buf, 3) + testFunc(t, buf, 3) }) t.Run("4", func(t *testing.T) { buf := make([]byte, 48)