1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-05 00:59:19 +02:00

remove caching of styles in gocui

This commit is contained in:
Jesse Duffield
2021-04-05 19:37:58 +10:00
parent 267da3b4db
commit 9593129e6a
4 changed files with 4 additions and 19 deletions

View File

@ -5,7 +5,6 @@
package gocui
import (
"sync"
"time"
"github.com/gdamore/tcell/v2"
@ -21,11 +20,6 @@ type oldStyle struct {
outputMode OutputMode
}
// we're using this cache to speed up rendering, because obtaining the tcell style
// from the old style is deterministic
var cellStyleCache map[oldStyle]tcell.Style = map[oldStyle]tcell.Style{}
var cacheMutex = sync.RWMutex{}
// tcellInit initializes tcell screen for use.
func tcellInit() error {
if s, e := tcell.NewScreen(); e != nil {
@ -58,13 +52,6 @@ func tcellSetCell(x, y int, ch rune, fg, bg Attribute, outputMode OutputMode) {
// getTcellStyle creates tcell.Style from Attributes
func getTcellStyle(input oldStyle) tcell.Style {
cacheMutex.RLock()
cachedResult, ok := cellStyleCache[input]
cacheMutex.RUnlock()
if ok {
return cachedResult
}
st := tcell.StyleDefault
// extract colors and attributes
@ -77,10 +64,6 @@ func getTcellStyle(input oldStyle) tcell.Style {
st = setTcellFontEffectStyle(st, input.bg)
}
cacheMutex.Lock()
cellStyleCache[input] = st
cacheMutex.Unlock()
return st
}