mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: reduce a little memory
This commit is contained in:
parent
7be3e617ab
commit
b2981f921c
|
@ -7,6 +7,10 @@ type Node struct {
|
|||
}
|
||||
|
||||
func (n *Node) getChild(s string) *Node {
|
||||
if n.children == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return n.children[s]
|
||||
}
|
||||
|
||||
|
@ -15,12 +19,16 @@ func (n *Node) hasChild(s string) bool {
|
|||
}
|
||||
|
||||
func (n *Node) addChild(s string, child *Node) {
|
||||
if n.children == nil {
|
||||
n.children = map[string]*Node{}
|
||||
}
|
||||
|
||||
n.children[s] = child
|
||||
}
|
||||
|
||||
func newNode(data any) *Node {
|
||||
return &Node{
|
||||
Data: data,
|
||||
children: map[string]*Node{},
|
||||
children: nil,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user