优化: 资源消耗优化,发布 v0.2.1
This commit is contained in:
@@ -222,11 +222,19 @@ func (m *Model) moveHistorySess(dir int) {
|
||||
|
||||
func (m *Model) currentSessions() []*Session {
|
||||
if m.history.DirCursor == 0 {
|
||||
var all []*Session
|
||||
for _, pd := range m.history.Projects {
|
||||
all = append(all, pd.Sessions...)
|
||||
if m.allSessionsDirty || m.allSessionsCache == nil {
|
||||
total := 0
|
||||
for _, pd := range m.history.Projects {
|
||||
total += len(pd.Sessions)
|
||||
}
|
||||
all := make([]*Session, 0, total)
|
||||
for _, pd := range m.history.Projects {
|
||||
all = append(all, pd.Sessions...)
|
||||
}
|
||||
m.allSessionsCache = all
|
||||
m.allSessionsDirty = false
|
||||
}
|
||||
return all
|
||||
return m.allSessionsCache
|
||||
}
|
||||
if m.history.DirCursor == 1 {
|
||||
return collectFavorites(m.history.Projects, m.history.Favorites)
|
||||
|
||||
Reference in New Issue
Block a user