From c47f9303b00b3cb6f4b4af4e10edacce5624998d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 30 Apr 2024 15:25:06 -0700 Subject: [PATCH] types/views: use slices.Contains{,Func} Updates #8419 Change-Id: Ib1a9cb3fb425284b7e02684072a4e7a35975f35c Signed-off-by: Brad Fitzpatrick --- types/views/views.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/types/views/views.go b/types/views/views.go index 7ff0234a4..379b80c59 100644 --- a/types/views/views.go +++ b/types/views/views.go @@ -286,22 +286,12 @@ func (v Slice[T]) ContainsFunc(f func(T) bool) bool { // // As it runs in O(n) time, use with care. func SliceContains[T comparable](v Slice[T], e T) bool { - for _, x := range v.ж { - if x == e { - return true - } - } - return false + return slices.Contains(v.ж, e) } // SliceContainsFunc reports whether f reports true for any element in v. func SliceContainsFunc[T any](v Slice[T], f func(T) bool) bool { - for _, x := range v.ж { - if f(x) { - return true - } - } - return false + return slices.ContainsFunc(v.ж, f) } // SliceEqual is like the standard library's slices.Equal, but for two views.