1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-12-01 22:52:01 +02:00

Store Pipe objects by value in slice of Pipes

This saves some memory at the cost of a slight performance increase (I suppose
reallocting the slice when adding new Pipes is slightly more expensive now).

Performance of the BenchmarkRenderCommitGraph benchmark is 130μs before, 175μs
after. I'm guessing this is still acceptable.
This commit is contained in:
Stefan Haller
2025-04-16 20:22:39 +02:00
parent 18e5b0a650
commit 28aa26f30a
3 changed files with 43 additions and 43 deletions

View File

@@ -28,7 +28,7 @@ type pipeSetCacheKey struct {
}
var (
pipeSetCache = make(map[pipeSetCacheKey][][]*graph.Pipe)
pipeSetCache = make(map[pipeSetCacheKey][][]graph.Pipe)
mutex deadlock.Mutex
)
@@ -245,7 +245,7 @@ func indexOfFirstNonTODOCommit(commits []*models.Commit) int {
return 0
}
func loadPipesets(commits []*models.Commit) [][]*graph.Pipe {
func loadPipesets(commits []*models.Commit) [][]graph.Pipe {
// given that our cache key is a commit hash and a commit count, it's very important that we don't actually try to render pipes
// when dealing with things like filtered commits.
cacheKey := pipeSetCacheKey{