Parcourir la source

:zap: Improve performance for API getBlockTreeInfos

Daniel il y a 8 mois
Parent
commit
e490b6e1f6
1 fichiers modifiés avec 2 ajouts et 20 suppressions
  1. 2 20
      kernel/model/block.go

+ 2 - 20
kernel/model/block.go

@@ -130,26 +130,8 @@ type BlockTreeInfo struct {
 
 func GetBlockTreeInfos(ids []string) (ret map[string]*BlockTreeInfo) {
 	ret = map[string]*BlockTreeInfo{}
-	luteEngine := util.NewLute()
-	treeCache := map[string]*parse.Tree{}
-	for _, id := range ids {
-		bt := treenode.GetBlockTree(id)
-		if nil == bt {
-			ret[id] = &BlockTreeInfo{ID: id}
-			continue
-		}
-
-		tree := treeCache[bt.RootID]
-		if nil == tree {
-			tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
-			if nil == tree {
-				ret[id] = &BlockTreeInfo{ID: id}
-				continue
-			}
-
-			treeCache[bt.RootID] = tree
-		}
-
+	trees := filesys.LoadTrees(ids)
+	for id, tree := range trees {
 		node := treenode.GetNodeInTree(tree, id)
 		if nil == node {
 			ret[id] = &BlockTreeInfo{ID: id}