mirror of https://gitee.com/answerdev/answer.git
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:
parent
c8175744aa
commit
e1d320a047
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue