avoid extra string copy in Stringwidth
This commit is contained in:
parent
5c0858d6b7
commit
d16ad40bbf
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
package wcswidth
|
package wcswidth
|
||||||
|
|
||||||
|
import "kitty/tools/utils"
|
||||||
|
|
||||||
func IsFlagCodepoint(ch rune) bool {
|
func IsFlagCodepoint(ch rune) bool {
|
||||||
return 0x1F1E6 <= ch && ch <= 0x1F1FF
|
return 0x1F1E6 <= ch && ch <= 0x1F1FF
|
||||||
}
|
}
|
||||||
@ -89,5 +91,5 @@ func (self *WCWidthIterator) Parse(b []byte) (ans int) {
|
|||||||
|
|
||||||
func Stringwidth(text string) int {
|
func Stringwidth(text string) int {
|
||||||
w := CreateWCWidthIterator()
|
w := CreateWCWidthIterator()
|
||||||
return w.Parse([]byte(text))
|
return w.Parse(utils.UnsafeStringToBytes(text))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user