mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-20 11:00:52 +08:00
⚡ 改进打开虚拟引用后加载文档的性能 https://github.com/siyuan-note/siyuan/issues/7378
This commit is contained in:
parent
0eabe9bf5f
commit
b75a46a228
@ -54,20 +54,19 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
|
|||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
})
|
})
|
||||||
content := buf.String()
|
content := buf.String()
|
||||||
putBlockVirtualRefKeywords(content, root.ID, root.IALAttr("title"))
|
ret = putBlockVirtualRefKeywords(content, root.ID, root.IALAttr("title"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ret = val.([]string)
|
ret = val.([]string)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) {
|
func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) (ret []string) {
|
||||||
keywords := getVirtualRefKeywords(docTitle)
|
keywords := getVirtualRefKeywords(docTitle)
|
||||||
if 1 > len(keywords) {
|
if 1 > len(keywords) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var hitKeywords []string
|
|
||||||
contentTmp := blockContent
|
contentTmp := blockContent
|
||||||
if !Conf.Search.CaseSensitive {
|
if !Conf.Search.CaseSensitive {
|
||||||
contentTmp = strings.ToLower(blockContent)
|
contentTmp = strings.ToLower(blockContent)
|
||||||
@ -79,16 +78,17 @@ func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(contentTmp, keywordTmp) {
|
if strings.Contains(contentTmp, keywordTmp) {
|
||||||
hitKeywords = append(hitKeywords, keyword)
|
ret = append(ret, keyword)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if 1 > len(hitKeywords) {
|
if 1 > len(ret) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hitKeywords = gulu.Str.RemoveDuplicatedElem(hitKeywords)
|
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||||
virtualBlockRefCache.Set(blockID, hitKeywords, 1)
|
virtualBlockRefCache.Set(blockID, ret, 1)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func CacheVirtualBlockRefJob() {
|
func CacheVirtualBlockRefJob() {
|
||||||
|
Loading…
Reference in New Issue
Block a user