Skip to content

Commit 66e2d35

Browse files
yhabteaboxzi
authored andcommitted
utils: Drop unused Remove* utils functions
Imported from Icinga/icinga-notifications@aa3b0db
1 parent b16eb97 commit 66e2d35

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

utils/utils.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,6 @@ func PrintErrorThenExit(err error, exitCode int) {
166166
os.Exit(exitCode)
167167
}
168168

169-
func RemoveIf[T any](slice []T, pred func(T) bool) []T {
170-
n := len(slice)
171-
172-
for i := 0; i < n; i++ {
173-
for i < n && pred(slice[i]) {
174-
n--
175-
slice[i], slice[n] = slice[n], slice[i]
176-
}
177-
}
178-
179-
return slice[:n]
180-
}
181-
182-
func RemoveNils[T any](slice []*T) []*T {
183-
return RemoveIf(slice, func(ptr *T) bool {
184-
return ptr == nil
185-
})
186-
}
187-
188169
// IterateOrderedMap implements iter.Seq2 to iterate over a map in the key's order.
189170
//
190171
// This function returns a func yielding key-value-pairs from a given map in the order of their keys, if their type

utils/utils_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,6 @@ func requireClosedEmpty(t *testing.T, ch <-chan int) {
5454
}
5555
}
5656

57-
func TestRemoveNils(t *testing.T) {
58-
var a, b, c, d int
59-
60-
tests := []struct {
61-
name string
62-
in []*int
63-
want []*int
64-
}{
65-
{"Empty", []*int{}, []*int{}},
66-
{"SingleKeep", []*int{&a}, []*int{&a}},
67-
{"SingleRemove", []*int{nil}, []*int{}},
68-
{"KeepOrder", []*int{&a, &b, &c, &d}, []*int{&a, &b, &c, &d}},
69-
{"Duplicates", []*int{&a, &b, &b}, []*int{&a, &b, &b}},
70-
{"Mixed", []*int{&a, nil, &b, nil, nil, &b, nil, &d}, []*int{&a, &b, &b, &d}},
71-
}
72-
for _, tt := range tests {
73-
t.Run(tt.name, func(t *testing.T) {
74-
assert.Equal(t, tt.want, RemoveNils(tt.in))
75-
})
76-
}
77-
}
78-
7957
func TestIterateOrderedMap(t *testing.T) {
8058
tests := []struct {
8159
name string

0 commit comments

Comments
 (0)