Skip to content

Commit

Permalink
inherit custom PathTrie segmenter in child nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
XANi committed May 6, 2021
1 parent f9cf546 commit 40e58ab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion path_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func NewPathTrieWithConfig(config *PathTrieConfig) *PathTrie {
}
}

// newPathTrieFromTrie returns new trie while preserving its config
func (trie *PathTrie) newPathTrie() *PathTrie {
return &PathTrie{
segmenter: trie.segmenter,
}
}

// Get returns the value stored at the given key. Returns nil for internal
// nodes or for nodes with a value of nil.
func (trie *PathTrie) Get(key string) interface{} {
Expand All @@ -64,7 +71,7 @@ func (trie *PathTrie) Put(key string, value interface{}) bool {
if node.children == nil {
node.children = map[string]*PathTrie{}
}
child = NewPathTrie()
child = trie.newPathTrie()
node.children[part] = child
}
node = child
Expand Down

0 comments on commit 40e58ab

Please sign in to comment.