mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 18:26:09 +01:00
⚡ 改进重命名资源文件性能 https://github.com/siyuan-note/siyuan/issues/7322
改进建立引用索引 https://github.com/siyuan-note/siyuan/issues/7320
This commit is contained in:
parent
6743b21193
commit
b6ea32462e
23 changed files with 155 additions and 132 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/editor"
|
||||
"github.com/88250/lute/lex"
|
||||
|
|
@ -34,6 +35,7 @@ import (
|
|||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -419,8 +421,7 @@ func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
|
||||
data := strings.ReplaceAll(operation.Data.(string), editor.FrontEndCaret, "")
|
||||
luteEngine := NewLute()
|
||||
subTree := luteEngine.BlockDOM2Tree(data)
|
||||
subTree := tx.luteEngine.BlockDOM2Tree(data)
|
||||
insertedNode := subTree.Root.FirstChild
|
||||
if nil == insertedNode {
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, msg: "invalid data tree", id: block.ID}
|
||||
|
|
@ -507,8 +508,7 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
|
||||
data := strings.ReplaceAll(operation.Data.(string), editor.FrontEndCaret, "")
|
||||
luteEngine := NewLute()
|
||||
subTree := luteEngine.BlockDOM2Tree(data)
|
||||
subTree := tx.luteEngine.BlockDOM2Tree(data)
|
||||
insertedNode := subTree.Root.FirstChild
|
||||
if nil == insertedNode {
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, msg: "invalid data tree", id: block.ID}
|
||||
|
|
@ -720,8 +720,7 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
|
||||
data := strings.ReplaceAll(operation.Data.(string), editor.FrontEndCaret, "")
|
||||
luteEngine := NewLute()
|
||||
subTree := luteEngine.BlockDOM2Tree(data)
|
||||
subTree := tx.luteEngine.BlockDOM2Tree(data)
|
||||
|
||||
p := block.Path
|
||||
assets := getAssetsDir(filepath.Join(util.DataDir, block.BoxID), filepath.Dir(filepath.Join(util.DataDir, block.BoxID, p)))
|
||||
|
|
@ -870,8 +869,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
||||
}
|
||||
|
||||
luteEngine := NewLute()
|
||||
subTree := luteEngine.BlockDOM2Tree(data)
|
||||
subTree := tx.luteEngine.BlockDOM2Tree(data)
|
||||
subTree.ID, subTree.Box, subTree.Path = tree.ID, tree.Box, tree.Path
|
||||
oldNode := treenode.GetNodeInTree(tree, id)
|
||||
if nil == oldNode {
|
||||
|
|
@ -1034,6 +1032,8 @@ type Transaction struct {
|
|||
|
||||
trees map[string]*parse.Tree
|
||||
nodes map[string]*ast.Node
|
||||
|
||||
luteEngine *lute.Lute
|
||||
}
|
||||
|
||||
func (tx *Transaction) begin() (err error) {
|
||||
|
|
@ -1042,6 +1042,7 @@ func (tx *Transaction) begin() (err error) {
|
|||
}
|
||||
tx.trees = map[string]*parse.Tree{}
|
||||
tx.nodes = map[string]*ast.Node{}
|
||||
tx.luteEngine = util.NewLute()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1077,7 +1078,7 @@ func (tx *Transaction) loadTree(id string) (ret *parse.Tree, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
ret, err = LoadTree(box, p)
|
||||
ret, err = filesys.LoadTree(box, p, tx.luteEngine)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue