🎨 改进打开虚拟引用后加载文档的性能 https://github.com/siyuan-note/siyuan/issues/7378

This commit is contained in:
Liang Ding 2023-02-16 12:33:22 +08:00
parent 7d05f4e8c7
commit e89f706864
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
5 changed files with 9 additions and 16 deletions

View File

@ -221,7 +221,6 @@ func setSearch(c *gin.Context) {
if s.CaseSensitive != oldCaseSensitive {
model.FullReindex()
}
sql.ClearVirtualRefKeywords()
ret.Data = s
}

View File

@ -167,7 +167,7 @@ func buildBacklink(refID string, refTree *parse.Tree, keywords []string, luteEng
return ast.WalkContinue
}
markReplaceSpan(n, &unlinks, keywords, searchMarkDataType, luteEngine)
markReplaceSpan(n, &unlinks, keywords, search.MarkDataType, luteEngine)
return ast.WalkContinue
})
@ -690,7 +690,7 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
continue
}
newText := markReplaceSpanWithSplit(text, mentionKeywords, getMarkSpanStart(searchMarkDataType), getMarkSpanEnd())
newText := markReplaceSpanWithSplit(text, mentionKeywords, search.GetMarkSpanStart(search.MarkDataType), search.GetMarkSpanEnd())
if text != newText {
tmp = append(tmp, b)
}

View File

@ -180,7 +180,7 @@ func GetDocHistoryContent(historyPath, keyword string) (id, rootID, content stri
n.RemoveIALAttr("fold")
if 0 < len(keywords) {
if markReplaceSpan(n, &unlinks, keywords, searchMarkDataType, luteEngine) {
if markReplaceSpan(n, &unlinks, keywords, search.MarkDataType, luteEngine) {
return ast.WalkContinue
}
}

View File

@ -29,11 +29,6 @@ import (
)
func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string) {
ret, ok := getVirtualRefKeywordsCache()
if ok {
return ret
}
if name {
ret = append(ret, queryNames()...)
}
@ -50,7 +45,6 @@ func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string) {
sort.SliceStable(ret, func(i, j int) bool {
return len(ret[i]) >= len(ret[j])
})
setVirtualRefKeywords(ret)
return
}

View File

@ -67,7 +67,7 @@ func InitDatabase(forceRebuild bool) (err error) {
initDatabaseLock.Lock()
defer initDatabaseLock.Unlock()
ClearBlockCache()
ClearCache()
disableCache()
defer enableCache()
@ -888,7 +888,7 @@ func deleteBlocksByBoxTx(tx *sql.Tx, box string) (err error) {
if err = execStmtTx(tx, stmt, box); nil != err {
return
}
ClearBlockCache()
ClearCache()
return
}
@ -1012,7 +1012,7 @@ func deleteByRootID(tx *sql.Tx, rootID string, context map[string]interface{}) (
if err = execStmtTx(tx, stmt, rootID); nil != err {
return
}
ClearBlockCache()
ClearCache()
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, rootID)
return
}
@ -1048,7 +1048,7 @@ func batchDeleteByRootIDs(tx *sql.Tx, rootIDs []string, context map[string]inter
if err = execStmtTx(tx, stmt); nil != err {
return
}
ClearBlockCache()
ClearCache()
eventbus.Publish(eventbus.EvtSQLDeleteBlocks, context, fmt.Sprintf("%d", len(rootIDs)))
return
}
@ -1082,7 +1082,7 @@ func batchDeleteByPathPrefix(tx *sql.Tx, boxID, pathPrefix string) (err error) {
if err = execStmtTx(tx, stmt, boxID, pathPrefix+"%"); nil != err {
return
}
ClearBlockCache()
ClearCache()
return
}
@ -1099,7 +1099,7 @@ func batchUpdateHPath(tx *sql.Tx, boxID, rootID, oldHPath, newHPath string) (err
if err = execStmtTx(tx, stmt, newHPath, boxID, rootID, oldHPath); nil != err {
return
}
ClearBlockCache()
ClearCache()
return
}