Skip to content
Myr

Improve rendering performance by caching rune widths

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent a47c06c · Browse files · 1 file+6 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Related: 8bead4a

Diff stats

1 file+6 added−1 removed

  • other:+6 added−1 removed

1 file+6 added−1 removed

modified:src/terminal.go+6 added-1 removed
60 unmodified lines
61 return a[i].at.Before(a[j].at)62}6364var _spinner = []string{`-`, `\`, `|`, `/`, `-`, `\`, `|`, `/`}65var _runeWidths = make(map[rune]int)6667const (68 reqPrompt util.EventType = iota69 reqInfo
106 unmodified lines
176177func runeWidth(r rune, prefixWidth int) int {178 if r == '\t' {179 return 8 - prefixWidth%8180 } else if w, found := _runeWidths[r]; found {181 return w182 } else {180 return runewidth.RuneWidth(r)183 w := runewidth.RuneWidth(r)184 _runeWidths[r] = w185 return w186 }187}188189func displayWidth(runes []rune) int {
527 unmodified lines