fix: unused slice methods

Carlos Alexandro Becker created

Change summary

internal/csync/slices.go      | 16 ----------------
internal/csync/slices_test.go | 19 ++++++-------------
2 files changed, 6 insertions(+), 29 deletions(-)

Detailed changes

internal/csync/slices.go 🔗

@@ -112,15 +112,6 @@ func (s *Slice[T]) Len() int {
 	return len(s.inner)
 }
 
-// Slice returns a copy of the underlying slice.
-func (s *Slice[T]) Slice() []T {
-	s.mu.RLock()
-	defer s.mu.RUnlock()
-	result := make([]T, len(s.inner))
-	copy(result, s.inner)
-	return result
-}
-
 // SetSlice replaces the entire slice with a new one.
 func (s *Slice[T]) SetSlice(items []T) {
 	s.mu.Lock()
@@ -129,13 +120,6 @@ func (s *Slice[T]) SetSlice(items []T) {
 	copy(s.inner, items)
 }
 
-// Clear removes all elements from the slice.
-func (s *Slice[T]) Clear() {
-	s.mu.Lock()
-	defer s.mu.Unlock()
-	s.inner = s.inner[:0]
-}
-
 // Seq returns an iterator that yields elements from the slice.
 func (s *Slice[T]) Seq() iter.Seq[T] {
 	return func(yield func(T) bool) {

internal/csync/slices_test.go 🔗

@@ -1,6 +1,7 @@
 package csync
 
 import (
+	"slices"
 	"sync"
 	"sync/atomic"
 	"testing"
@@ -145,7 +146,7 @@ func TestSlice(t *testing.T) {
 		assert.Equal(t, 4, s.Len())
 
 		expected := []int{1, 2, 4, 5}
-		actual := s.Slice()
+		actual := slices.Collect(s.Seq())
 		assert.Equal(t, expected, actual)
 
 		// Delete out of bounds
@@ -203,7 +204,7 @@ func TestSlice(t *testing.T) {
 		s.SetSlice(newItems)
 
 		assert.Equal(t, 3, s.Len())
-		assert.Equal(t, newItems, s.Slice())
+		assert.Equal(t, newItems, slices.Collect(s.Seq()))
 
 		// Verify it's a copy
 		newItems[0] = 999
@@ -212,23 +213,15 @@ func TestSlice(t *testing.T) {
 		assert.Equal(t, 10, val)
 	})
 
-	t.Run("Clear", func(t *testing.T) {
-		s := NewSliceFrom([]int{1, 2, 3})
-		assert.Equal(t, 3, s.Len())
-
-		s.Clear()
-		assert.Equal(t, 0, s.Len())
-	})
-
 	t.Run("Slice", func(t *testing.T) {
 		original := []int{1, 2, 3}
 		s := NewSliceFrom(original)
 
-		copy := s.Slice()
-		assert.Equal(t, original, copy)
+		copied := slices.Collect(s.Seq())
+		assert.Equal(t, original, copied)
 
 		// Verify it's a copy
-		copy[0] = 999
+		copied[0] = 999
 		val, ok := s.Get(0)
 		require.True(t, ok)
 		assert.Equal(t, 1, val)