Skip to content

Commit

Permalink
std: switch trie to TlvStr()
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Feb 3, 2025
1 parent de9c6d5 commit 2e581c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions std/engine/basic/simple_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package basic
import enc "github.com/named-data/ndnd/std/encoding"

// NameTrie is a simple implementation of a Name trie (node/subtree) used for PIT and FIB.
// It is slow due to the usage of String(). Subject to change when it explicitly affects performance.
// It is slow due to the usage of TlvStr(). Subject to change when it explicitly affects performance.
type NameTrie[V any] struct {
val V
key string
Expand All @@ -27,7 +27,7 @@ func (n *NameTrie[V]) ExactMatch(name enc.Name) *NameTrie[V] {
if len(name) <= n.dep {
return n
}
c := name[n.dep].String()
c := name[n.dep].TlvStr()
if ch, ok := n.chd[c]; ok {
return ch.ExactMatch(name)
} else {
Expand All @@ -41,7 +41,7 @@ func (n *NameTrie[V]) PrefixMatch(name enc.Name) *NameTrie[V] {
if len(name) <= n.dep {
return n
}
c := name[n.dep].String()
c := name[n.dep].TlvStr()
if ch, ok := n.chd[c]; ok {
return ch.PrefixMatch(name)
} else {
Expand All @@ -68,7 +68,7 @@ func (n *NameTrie[V]) MatchAlways(name enc.Name) *NameTrie[V] {
if len(name) <= n.dep {
return n
}
c := name[n.dep].String()
c := name[n.dep].TlvStr()
ch, ok := n.chd[c]
if !ok {
ch = newTrieNode(c, n)
Expand All @@ -82,7 +82,7 @@ func (n *NameTrie[V]) FirstSatisfyOrNew(name enc.Name, pred func(V) bool) *NameT
if len(name) <= n.dep || pred(n.val) {
return n
}
c := name[n.dep].String()
c := name[n.dep].TlvStr()
ch, ok := n.chd[c]
if !ok {
ch = newTrieNode(c, n)
Expand Down

0 comments on commit 2e581c0

Please sign in to comment.