Decrease allocs when wrapping

This commit is contained in:
Kovid Goyal
2023-03-20 21:00:04 +05:30
parent 18b58c5cf9
commit e42b4fd9a6
2 changed files with 25 additions and 27 deletions

View File

@@ -122,6 +122,10 @@ func (self *WCWidthIterator) Parse(b []byte) (ans int) {
return self.current_width
}
func (self *WCWidthIterator) CurrentWidth() int {
return self.current_width
}
func Stringwidth(text string) int {
w := CreateWCWidthIterator()
return w.Parse(utils.UnsafeStringToBytes(text))