avoid extra string copy in Stringwidth

This commit is contained in:
Kovid Goyal 2022-09-18 10:42:43 +05:30
parent 5c0858d6b7
commit d16ad40bbf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -2,6 +2,8 @@
package wcswidth
import "kitty/tools/utils"
func IsFlagCodepoint(ch rune) bool {
return 0x1F1E6 <= ch && ch <= 0x1F1FF
}
@ -89,5 +91,5 @@ func (self *WCWidthIterator) Parse(b []byte) (ans int) {
func Stringwidth(text string) int {
w := CreateWCWidthIterator()
return w.Parse([]byte(text))
return w.Parse(utils.UnsafeStringToBytes(text))
}