⚡ Improve block ref searching performance https://github.com/siyuan-note/siyuan/issues/11951
This commit is contained in:
parent
f32b879a08
commit
27f88c2482
2 changed files with 12 additions and 2 deletions
|
@ -360,10 +360,15 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
|
|||
|
||||
ret = fullTextSearchRefBlock(keyword, beforeLen, onlyDoc)
|
||||
tmp := ret[:0]
|
||||
var btsID []string
|
||||
for _, b := range ret {
|
||||
btsID = append(btsID, b.RootID)
|
||||
}
|
||||
bts := treenode.GetBlockTrees(btsID)
|
||||
for _, b := range ret {
|
||||
tree := cachedTrees[b.RootID]
|
||||
if nil == tree {
|
||||
tree, _ = LoadTreeByBlockID(b.RootID)
|
||||
tree, _ = loadTreeByBlockTree(bts[b.RootID])
|
||||
}
|
||||
if nil == tree {
|
||||
continue
|
||||
|
@ -376,7 +381,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
|
|||
// `((` 引用候选中排除当前块的父块 https://github.com/siyuan-note/siyuan/issues/4538
|
||||
tree := cachedTrees[b.RootID]
|
||||
if nil == tree {
|
||||
tree, _ = LoadTreeByBlockID(b.RootID)
|
||||
tree, _ = loadTreeByBlockTree(bts[b.RootID])
|
||||
cachedTrees[b.RootID] = tree
|
||||
}
|
||||
if nil != tree {
|
||||
|
|
|
@ -212,6 +212,11 @@ func LoadTreeByBlockID(id string) (ret *parse.Tree, err error) {
|
|||
return nil, ErrTreeNotFound
|
||||
}
|
||||
|
||||
ret, err = loadTreeByBlockTree(bt)
|
||||
return
|
||||
}
|
||||
|
||||
func loadTreeByBlockTree(bt *treenode.BlockTree) (ret *parse.Tree, err error) {
|
||||
luteEngine := util.NewLute()
|
||||
ret, err = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue