mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 08:30:42 +02:00
⚡ Improve database loading performance https://github.com/siyuan-note/siyuan/issues/15115
This commit is contained in:
parent
b8f421978f
commit
2e2f152311
1 changed files with 24 additions and 0 deletions
|
@ -278,6 +278,21 @@ func nodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
|
||||
func BatchGetBlockAttrs(ids []string) (ret map[string]map[string]string) {
|
||||
ret = map[string]map[string]string{}
|
||||
|
||||
hitCache := true
|
||||
for _, id := range ids {
|
||||
ial := cache.GetBlockIAL(id)
|
||||
if nil != ial {
|
||||
ret[id] = ial
|
||||
continue
|
||||
}
|
||||
hitCache = false
|
||||
break
|
||||
}
|
||||
if hitCache {
|
||||
return
|
||||
}
|
||||
|
||||
trees := filesys.LoadTrees(ids)
|
||||
for _, id := range ids {
|
||||
tree := trees[id]
|
||||
|
@ -308,6 +323,15 @@ func GetBlockAttrs(id string) (ret map[string]string) {
|
|||
|
||||
func getBlockAttrsFromTree(id string, tree *parse.Tree) (ret map[string]string) {
|
||||
ret = map[string]string{}
|
||||
|
||||
ial := cache.GetBlockIAL(id)
|
||||
if nil != ial {
|
||||
for k, v := range ial {
|
||||
ret[k] = v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
if nil == node {
|
||||
logging.LogWarnf("block [%s] not found", id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue