Skip to content

Commit

Permalink
Refactor Contains function to improve performance by using index iter…
Browse files Browse the repository at this point in the history
…ation over collection (#428)

Co-authored-by: 关明 <guanming@ziipin.com>
  • Loading branch information
lennon-guan and 关明 authored Jun 27, 2024
1 parent 0f865a3 commit a966a64
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions intersect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package lo

// Contains returns true if an element is present in a collection.
func Contains[T comparable](collection []T, element T) bool {
for _, item := range collection {
if item == element {
for i := range collection {
if collection[i] == element {
return true
}
}
Expand Down

0 comments on commit a966a64

Please sign in to comment.