Improve load tree performance

This commit is contained in:
Daniel 2024-06-22 00:01:20 +08:00
parent cb16111314
commit 1452e7cf3f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 19 additions and 22 deletions

View file

@ -557,11 +557,16 @@ func (box *Box) UpdateHistoryGenerated() {
func getBoxesByPaths(paths []string) (ret map[string]*Box) {
ret = map[string]*Box{}
var ids []string
for _, p := range paths {
id := strings.TrimSuffix(path.Base(p), ".sy")
bt := treenode.GetBlockTree(id)
ids = append(ids, strings.TrimSuffix(path.Base(p), ".sy"))
}
bts := treenode.GetBlockTrees(ids)
for _, id := range ids {
bt := bts[id]
if nil != bt {
ret[p] = Conf.Box(bt.BoxID)
ret[bt.Path] = Conf.Box(bt.BoxID)
}
}
return