Improve block ref searching performance https://github.com/siyuan-note/siyuan/issues/11951

This commit is contained in:
Daniel 2024-07-14 11:48:56 +08:00
parent 27f88c2482
commit 338ed572da
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -324,10 +324,15 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
ignoreLines := getRefSearchIgnoreLines()
refs := sql.QueryRefsRecent(onlyDoc, ignoreLines)
var btsID []string
for _, ref := range refs {
btsID = append(btsID, ref.DefBlockRootID)
}
bts := treenode.GetBlockTrees(btsID)
for _, ref := range refs {
tree := cachedTrees[ref.DefBlockRootID]
if nil == tree {
tree, _ = LoadTreeByBlockID(ref.DefBlockRootID)
tree, _ = loadTreeByBlockTree(bts[ref.DefBlockRootID])
}
if nil == tree {
continue