Skip to content

Commit

Permalink
util: remove useless codes (#46096)
Browse files Browse the repository at this point in the history
ref #45933
  • Loading branch information
Defined2014 authored Aug 15, 2023
1 parent a15c017 commit 3846e80
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 60 deletions.
13 changes: 0 additions & 13 deletions util/slice/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,3 @@ func AllOf(s interface{}, p func(int) bool) bool {
}
return NoneOf(s, np)
}

// Copy is a deep copy of the slice.
func Copy[T any](a []*T) []*T {
b := make([]*T, len(a))
for i, p := range a {
if p == nil {
continue
}
v := *p
b[i] = &v
}
return b
}
16 changes: 0 additions & 16 deletions util/slice/slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,3 @@ func TestSlice(t *testing.T) {
})
}
}

func TestCopy(t *testing.T) {
type T int
v0, v1, v2, v3 := T(0), T(1), T(2), T(3)
s := []*T{&v0, &v1, &v2, &v3, nil}
e := Copy(s)
require.Equal(t, len(s), len(e))
for i := range s {
if s[i] == nil {
require.Nil(t, e[i])
} else {
require.Equal(t, *s[i], *e[i])
require.True(t, s[i] != e[i])
}
}
}
1 change: 0 additions & 1 deletion util/table-filter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go_library(
srcs = [
"column_filter.go",
"compat.go",
"helper.go",
"matchers.go",
"parser.go",
"table_filter.go",
Expand Down
7 changes: 5 additions & 2 deletions util/table-filter/column_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

package filter

import "strings"
import (
"slices"
"strings"
)

// ColumnFilter is a structure to check if a column should be included for processing.
type ColumnFilter interface {
Expand Down Expand Up @@ -43,7 +46,7 @@ func ParseColumnFilter(args []string) (ColumnFilter, error) {
}
}

reverse(p.rules)
slices.Reverse(p.rules)

return columnFilter(p.rules), nil
}
Expand Down
27 changes: 0 additions & 27 deletions util/table-filter/helper.go

This file was deleted.

3 changes: 2 additions & 1 deletion util/table-filter/table_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package filter

import (
"slices"
"strings"
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func Parse(args []string) (Filter, error) {
}
}

reverse(p.rules)
slices.Reverse(p.rules)

return tableFilter(p.rules), nil
}
Expand Down

0 comments on commit 3846e80

Please sign in to comment.