Use library implementation of Contains function
This commit is contained in:
parent
8281301869
commit
3b420f8b6c
16
common.go
16
common.go
@ -9,6 +9,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -116,7 +118,7 @@ type dbKanjiList []dbKanji
|
||||
|
||||
func (kanji *dbKanji) addTags(tags ...string) {
|
||||
for _, tag := range tags {
|
||||
if !hasString(tag, kanji.Tags) {
|
||||
if !slices.Contains(kanji.Tags, tag) {
|
||||
kanji.Tags = append(kanji.Tags, tag)
|
||||
}
|
||||
}
|
||||
@ -245,7 +247,7 @@ func writeDb(outputPath string, index dbIndex, recordData map[string]dbRecordLis
|
||||
|
||||
func appendStringUnique(target []string, source ...string) []string {
|
||||
for _, str := range source {
|
||||
if !hasString(str, target) {
|
||||
if !slices.Contains(target, str) {
|
||||
target = append(target, str)
|
||||
}
|
||||
}
|
||||
@ -253,16 +255,6 @@ func appendStringUnique(target []string, source ...string) []string {
|
||||
return target
|
||||
}
|
||||
|
||||
func hasString(needle string, haystack []string) bool {
|
||||
for _, value := range haystack {
|
||||
if needle == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func intersection(s1, s2 []string) []string {
|
||||
s := []string{}
|
||||
m := make(map[string]bool)
|
||||
|
Loading…
Reference in New Issue
Block a user