Skip to content

Commit

Permalink
refactor: using slices.Contains (ethereum-optimism#11521)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiweixie authored and samlaf committed Aug 20, 2024
1 parent 94f1ac1 commit eaad12b
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
)

Expand Down Expand Up @@ -154,7 +155,7 @@ func docGen(invariantsDir, docsDir string) error {

for _, contract := range docs {
filePath := filepath.Join(docsDir, contract.Name+".md")
alreadyWritten := contains(writtenFiles, filePath)
alreadyWritten := slices.Contains(writtenFiles, filePath)

// If the file has already been written, append the extra docs to the end.
// Otherwise, write the file from scratch.
Expand Down Expand Up @@ -253,12 +254,3 @@ func renderContractDoc(contract Contract, header bool) string {

return sb.String()
}

func contains(slice []string, item string) bool {
for _, v := range slice {
if v == item {
return true
}
}
return false
}

0 comments on commit eaad12b

Please sign in to comment.