Skip to content

Commit

Permalink
Update path.go
Browse files Browse the repository at this point in the history
  • Loading branch information
dboehm-avalabs committed Oct 16, 2023
1 parent e0c89ee commit 755bb89
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions x/merkledb/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ func (p Path) HasPrefix(prefix Path) bool {
return strings.HasPrefix(p.value, prefixWithoutPartialByte)
}

// iteratedHasPrefix checks if the provided prefix path is a prefix of the current path after having skipped [skipTokens] tokens first
// this has better performance than constructing the actual path via Skip() then calling HasPrefix because it avoids the []byte allocation
func (p Path) iteratedHasPrefix(skipTokens int, prefix Path) bool {
if p.tokensLength-skipTokens < prefix.tokensLength {
return false
Expand Down

0 comments on commit 755bb89

Please sign in to comment.