Update chinese.go

There is no reason to keep a count of Chinese characters only to do a count check and return a bool. Simply return true the first char we find.  Otherwise return false.
This commit is contained in:
Brandon Hansen 2022-10-27 14:31:02 -07:00 committed by LinkinStars
parent c8175744aa
commit e1d320a047
1 changed files with 2 additions and 4 deletions

View File

@ -3,12 +3,10 @@ package checker
import "unicode"
func IsChinese(str string) bool {
var count int
for _, v := range str {
if unicode.Is(unicode.Han, v) {
count++
break
return true
}
}
return count > 0
return false
}