Skip to content

Commit bbc0c64

Browse files
committed
trie: improve comment
1 parent eb8f7ac commit bbc0c64

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

trie/iterator.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type nodeIterator struct {
145145
err error // Failure set in case of an internal error in the iterator
146146

147147
resolver NodeResolver // optional node resolver for avoiding disk hits
148-
pool []*nodeIteratorState // local pool for iteratorstates
148+
pool []*nodeIteratorState // local pool for iterator states
149149
}
150150

151151
// errIteratorEnd is stored in nodeIterator.err when iteration is done.
@@ -550,26 +550,28 @@ func (it *nodeIterator) pop() {
550550
it.path = it.path[:last.pathlen]
551551
it.stack[len(it.stack)-1] = nil
552552
it.stack = it.stack[:len(it.stack)-1]
553-
// last is now unused
554-
it.putInPool(last)
553+
554+
it.putInPool(last) // last is now unused
555555
}
556556

557-
// reachedPath normalizes a path by truncating a terminator if present, and returns true if it is
558-
// greater than or equal to the target. Using this, the path of a value node embedded a full node
559-
// will compare less than the full node's children.
557+
// reachedPath normalizes a path by truncating a terminator if present, and
558+
// returns true if it is greater than or equal to the target. Using this,
559+
// the path of a value node embedded a full node will compare less than the
560+
// full node's children.
560561
func reachedPath(path, target []byte) bool {
561562
if hasTerm(path) {
562563
path = path[:len(path)-1]
563564
}
564565
return bytes.Compare(path, target) >= 0
565566
}
566567

567-
// A value embedded in a full node occupies the last slot (16) of the array of children. In order to
568-
// produce a pre-order traversal when iterating children, we jump to this last slot first, then go
569-
// back iterate the child nodes (and skip the last slot at the end):
568+
// A value embedded in a full node occupies the last slot (16) of the array of
569+
// children. In order to produce a pre-order traversal when iterating children,
570+
// we jump to this last slot first, then go back iterate the child nodes (and
571+
// skip the last slot at the end):
570572

571-
// prevChildIndex returns the index of a child in a full node which precedes the given index when
572-
// performing a pre-order traversal.
573+
// prevChildIndex returns the index of a child in a full node which precedes
574+
// the given index when performing a pre-order traversal.
573575
func prevChildIndex(index int) int {
574576
switch index {
575577
case 0: // We jumped back to iterate the children, from the value slot
@@ -583,8 +585,8 @@ func prevChildIndex(index int) int {
583585
}
584586
}
585587

586-
// nextChildIndex returns the index of a child in a full node which follows the given index when
587-
// performing a pre-order traversal.
588+
// nextChildIndex returns the index of a child in a full node which follows
589+
// the given index when performing a pre-order traversal.
588590
func nextChildIndex(index int) int {
589591
switch index {
590592
case -1: // Jump from the placeholder index to the embedded value slot

0 commit comments

Comments
 (0)