Improve loading doc performance

This commit is contained in:
Daniel 2024-06-23 21:52:04 +08:00
parent 06f3721fd4
commit 9c4b8bd74c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 4 additions and 8 deletions

View file

@ -872,7 +872,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
luteEngine.RenderOptions.NodeIndexStart = index
dom = luteEngine.Tree2BlockDOM(subTree, luteEngine.RenderOptions)
SetRecentDocByTree(tree)
go setRecentDocByTree(tree)
return
}

View file

@ -63,17 +63,13 @@ func RemoveRecentDoc(ids []string) {
return
}
func SetRecentDocByTree(tree *parse.Tree) {
func setRecentDocByTree(tree *parse.Tree) {
recentDoc := &RecentDoc{
RootID: tree.Root.ID,
Icon: tree.Root.IALAttr("icon"),
Title: tree.Root.IALAttr("title"),
}
SetRecentDoc(recentDoc)
}
func SetRecentDoc(doc *RecentDoc) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
@ -83,13 +79,13 @@ func SetRecentDoc(doc *RecentDoc) (err error) {
}
for i, c := range recentDocs {
if c.RootID == doc.RootID {
if c.RootID == recentDoc.RootID {
recentDocs = append(recentDocs[:i], recentDocs[i+1:]...)
break
}
}
recentDocs = append([]*RecentDoc{doc}, recentDocs...)
recentDocs = append([]*RecentDoc{recentDoc}, recentDocs...)
if 32 < len(recentDocs) {
recentDocs = recentDocs[:32]
}