feat: use trie

上级 9b9742bd
......@@ -7,6 +7,7 @@ require (
github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab
github.com/boyter/scc v2.10.1+incompatible
github.com/dbaggerman/cuba v0.3.2 // indirect
github.com/dghubble/trie v0.0.0-20200716043226-5a94efb202d5
github.com/huleTW/bad-smell-analysis v0.1.0
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
github.com/mattn/go-shellwords v1.0.6
......
......@@ -2,6 +2,7 @@ package tequila
import (
"github.com/awalterschulze/gographviz"
"github.com/dghubble/trie"
"sort"
"strconv"
"strings"
......@@ -202,6 +203,11 @@ type GraphNode struct {
func (fullGraph *FullGraph) BuildMapTree(split string, include func(key string) bool) *GraphNode {
graphNode := &GraphNode{}
pkgTrie := trie.NewPathTrie()
for nodeKey := range fullGraph.NodeList {
pkgTrie.Put(strings.ReplaceAll(nodeKey, ".", "/"), 0)
}
for nodeKey := range fullGraph.NodeList {
tmp := strings.Split(nodeKey, split)
graphNode.text = tmp[0]
......@@ -211,6 +217,7 @@ func (fullGraph *FullGraph) BuildMapTree(split string, include func(key string)
return graphNode
}
func buildNode(arr []string, node *GraphNode) *GraphNode {
if node.text == arr[0] {
return node
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册