Skip to content

Commit d30b1b3

Browse files
committed
nodeHeaderShift constant
1 parent c70a163 commit d30b1b3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

internal/trie/node/header.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ const (
1414
// encodeHeader creates the encoded header for the branch.
1515
func (b *Branch) encodeHeader(writer io.Writer) (err error) {
1616
var header byte
17+
const nodeHeaderShift = 6
1718
if b.Value == nil {
18-
header = byte(BranchType) << 6
19+
header = byte(BranchType) << nodeHeaderShift
1920
} else {
20-
header = byte(BranchWithValueType) << 6
21+
header = byte(BranchWithValueType) << nodeHeaderShift
2122
}
2223

2324
if len(b.Key) >= keyLenOffset {
@@ -44,7 +45,8 @@ func (b *Branch) encodeHeader(writer io.Writer) (err error) {
4445

4546
// encodeHeader creates the encoded header for the leaf.
4647
func (l *Leaf) encodeHeader(writer io.Writer) (err error) {
47-
header := byte(LeafType) << 6
48+
const nodeHeaderShift = 6
49+
header := byte(LeafType) << nodeHeaderShift
4850

4951
if len(l.Key) < 63 {
5052
header |= byte(len(l.Key))

0 commit comments

Comments
 (0)