mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
⚡ Improve performance for API getBlockTreeInfos
This commit is contained in:
parent
da84195df3
commit
e490b6e1f6
1 changed files with 2 additions and 20 deletions
|
|
@ -130,26 +130,8 @@ type BlockTreeInfo struct {
|
||||||
|
|
||||||
func GetBlockTreeInfos(ids []string) (ret map[string]*BlockTreeInfo) {
|
func GetBlockTreeInfos(ids []string) (ret map[string]*BlockTreeInfo) {
|
||||||
ret = map[string]*BlockTreeInfo{}
|
ret = map[string]*BlockTreeInfo{}
|
||||||
luteEngine := util.NewLute()
|
trees := filesys.LoadTrees(ids)
|
||||||
treeCache := map[string]*parse.Tree{}
|
for id, tree := range trees {
|
||||||
for _, id := range ids {
|
|
||||||
bt := treenode.GetBlockTree(id)
|
|
||||||
if nil == bt {
|
|
||||||
ret[id] = &BlockTreeInfo{ID: id}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
tree := treeCache[bt.RootID]
|
|
||||||
if nil == tree {
|
|
||||||
tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
|
|
||||||
if nil == tree {
|
|
||||||
ret[id] = &BlockTreeInfo{ID: id}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
treeCache[bt.RootID] = tree
|
|
||||||
}
|
|
||||||
|
|
||||||
node := treenode.GetNodeInTree(tree, id)
|
node := treenode.GetNodeInTree(tree, id)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
ret[id] = &BlockTreeInfo{ID: id}
|
ret[id] = &BlockTreeInfo{ID: id}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue