mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
⚡ Improve performance
This commit is contained in:
parent
88a2835d5d
commit
9e48a23a93
1 changed files with 5 additions and 26 deletions
|
|
@ -1449,38 +1449,17 @@ func (tx *Transaction) doRemoveAttrViewView(operation *Operation) (ret *TxErr) {
|
||||||
|
|
||||||
func getMirrorBlocksNodes(avID string) (trees []*parse.Tree, nodes []*ast.Node) {
|
func getMirrorBlocksNodes(avID string) (trees []*parse.Tree, nodes []*ast.Node) {
|
||||||
mirrorBlockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
|
mirrorBlockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
|
||||||
mirrorBlockTree := map[string]*parse.Tree{}
|
mirrorBlockTrees := filesys.LoadTrees(mirrorBlockIDs)
|
||||||
treeCache := map[string]*parse.Tree{}
|
for id, tree := range mirrorBlockTrees {
|
||||||
for _, mirrorBlock := range mirrorBlockIDs {
|
node := treenode.GetNodeInTree(tree, id)
|
||||||
bt := treenode.GetBlockTree(mirrorBlock)
|
|
||||||
if nil == bt {
|
|
||||||
logging.LogErrorf("get block tree by block ID [%s] failed", mirrorBlock)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
tree := mirrorBlockTree[mirrorBlock]
|
|
||||||
if nil == tree {
|
|
||||||
tree, _ = LoadTreeByBlockID(mirrorBlock)
|
|
||||||
if nil == tree {
|
|
||||||
logging.LogErrorf("load tree by block ID [%s] failed", mirrorBlock)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
treeCache[tree.ID] = tree
|
|
||||||
mirrorBlockTree[mirrorBlock] = tree
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, mirrorBlockID := range mirrorBlockIDs {
|
|
||||||
tree := mirrorBlockTree[mirrorBlockID]
|
|
||||||
node := treenode.GetNodeInTree(tree, mirrorBlockID)
|
|
||||||
if nil == node {
|
if nil == node {
|
||||||
logging.LogErrorf("get node in tree by block ID [%s] failed", mirrorBlockID)
|
logging.LogErrorf("get node in tree by block ID [%s] failed", id)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tree := range treeCache {
|
for _, tree := range mirrorBlockTrees {
|
||||||
trees = append(trees, tree)
|
trees = append(trees, tree)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue