Skip to content

Commit d1afa6d

Browse files
committed
Drop unused Remove* utils functions
1 parent f0074b8 commit d1afa6d

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

internal/utils/utils.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,6 @@ func ToDBInt(value int64) types.Int {
139139
return val
140140
}
141141

142-
func RemoveIf[T any](slice []T, pred func(T) bool) []T {
143-
n := len(slice)
144-
145-
for i := 0; i < n; i++ {
146-
for i < n && pred(slice[i]) {
147-
n--
148-
slice[i], slice[n] = slice[n], slice[i]
149-
}
150-
}
151-
152-
return slice[:n]
153-
}
154-
155-
func RemoveNils[T any](slice []*T) []*T {
156-
return RemoveIf(slice, func(ptr *T) bool {
157-
return ptr == nil
158-
})
159-
}
160-
161142
// IterateOrderedMap implements iter.Seq2 to iterate over a map in the key's order.
162143
//
163144
// This function returns a func yielding key-value-pairs from a given map in the order of their keys, if their type

internal/utils/utils_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,6 @@ import (
55
"testing"
66
)
77

8-
func TestRemoveNils(t *testing.T) {
9-
var a, b, c, d int
10-
11-
tests := []struct {
12-
name string
13-
in []*int
14-
want []*int
15-
}{
16-
{"Empty", []*int{}, []*int{}},
17-
{"SingleKeep", []*int{&a}, []*int{&a}},
18-
{"SingleRemove", []*int{nil}, []*int{}},
19-
{"KeepOrder", []*int{&a, &b, &c, &d}, []*int{&a, &b, &c, &d}},
20-
{"Duplicates", []*int{&a, &b, &b}, []*int{&a, &b, &b}},
21-
{"Mixed", []*int{&a, nil, &b, nil, nil, &b, nil, &d}, []*int{&a, &b, &b, &d}},
22-
}
23-
for _, tt := range tests {
24-
t.Run(tt.name, func(t *testing.T) {
25-
assert.Equal(t, tt.want, RemoveNils(tt.in))
26-
})
27-
}
28-
}
29-
308
func TestIterateOrderedMap(t *testing.T) {
319
tests := []struct {
3210
name string

0 commit comments

Comments
 (0)