mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
This in itself is not an improvement, because hashes are unique (they are shared between real commits and rebase todos, but there are so few of those that it doesn't matter). However, it becomes an improvement once we also store parent hashes in the same pool; but the real motivation for this change is to also reuse the hash pointers in Pipe objects later in the branch. This will be a big win because in a merge-heavy git repo there are many more Pipe instances than commits.
14 lines
319 B
Go
14 lines
319 B
Go
package utils
|
|
|
|
import "sync"
|
|
|
|
// A simple string pool implementation that can help reduce memory usage for
|
|
// cases where the same string is used multiple times.
|
|
type StringPool struct {
|
|
sync.Map
|
|
}
|
|
|
|
func (self *StringPool) Add(s string) *string {
|
|
poolEntry, _ := self.LoadOrStore(s, &s)
|
|
return poolEntry.(*string)
|
|
}
|