1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-02 23:27:32 +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

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/imdario/mergo v0.3.11
github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
github.com/jesseduffield/gocui v0.3.1-0.20210405041826-439abd8b6e07
github.com/jesseduffield/gocui v0.3.1-0.20210405093708-e79dab8f7772
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect
github.com/jesseduffield/yaml v2.1.0+incompatible
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0

2
go.sum
View File

@ -100,6 +100,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20210403045716-a3be78c4ccf6 h1:nENhj0TKu
github.com/jesseduffield/gocui v0.3.1-0.20210403045716-a3be78c4ccf6/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/gocui v0.3.1-0.20210405041826-439abd8b6e07 h1:BymGR28auSeuW0QELl0JomK0iFLPS/WRjFlc1iGZiOQ=
github.com/jesseduffield/gocui v0.3.1-0.20210405041826-439abd8b6e07/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/gocui v0.3.1-0.20210405093708-e79dab8f7772 h1:dg9krj10Udac4IcvlVCOAPktQkfggkgtqRmbDKk7Pzw=
github.com/jesseduffield/gocui v0.3.1-0.20210405093708-e79dab8f7772/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe h1:qsVhCf2RFyyKIUe/+gJblbCpXMUki9rZrHuEctg6M/E=
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4=
github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE=

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
}

2
vendor/modules.txt vendored
View File

@ -149,7 +149,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
# github.com/jesseduffield/gocui v0.3.1-0.20210405041826-439abd8b6e07
# github.com/jesseduffield/gocui v0.3.1-0.20210405093708-e79dab8f7772
## explicit
github.com/jesseduffield/gocui
# github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe