[#447] pilorama: Use named constant for the key size

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-06-20 13:39:18 +03:00 committed by Evgenii Stratonikov
parent b4ce0b0412
commit 4bf345225c
2 changed files with 13 additions and 9 deletions

View file

@ -64,7 +64,7 @@ func (b *batch) run() {
// See TestForest_ApplySameOperation for details.
// 3. Parent of each operation is already in tree.
var parents map[uint64]struct{}
var cKey [17]byte
var cKey [maxKeySize]byte
var slow bool
for i := range b.operations {
_, _, _, inTree := b.forest.getState(bTree, stateKey(cKey[:], b.operations[i].Child))
@ -75,7 +75,7 @@ func (b *batch) run() {
key := childrenKey(cKey[:], b.operations[i].Child, 0)
k, _ := bTree.Cursor().Seek(key)
if len(k) == 17 && binary.LittleEndian.Uint64(k[1:]) == b.operations[i].Child {
if len(k) == childrenKeySize && binary.LittleEndian.Uint64(k[1:]) == b.operations[i].Child {
slow = true
break
}
@ -104,9 +104,8 @@ func (b *batch) run() {
return b.forest.applyOperation(bLog, bTree, b.operations, &lm)
}
var key [17]byte
for i := range b.operations {
if err := b.forest.do(bLog, bTree, key[:], b.operations[i]); err != nil {
if err := b.forest.do(bLog, bTree, cKey[:], b.operations[i]); err != nil {
return err
}
}