mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/storage: avoid superflouos copy of block header data
This commit is contained in:
parent
34aa25d681
commit
463bc27312
@ -223,15 +223,14 @@ func (bsr *blockStreamReader) readBlock() error {
|
||||
return fmt.Errorf("too short index data for reading block header at offset %d; got %d bytes; want %d bytes",
|
||||
bsr.prevIndexBlockOffset(), len(bsr.indexCursor), marshaledBlockHeaderSize)
|
||||
}
|
||||
bsr.Block.headerData = append(bsr.Block.headerData[:0], bsr.indexCursor[:marshaledBlockHeaderSize]...)
|
||||
bsr.indexCursor = bsr.indexCursor[marshaledBlockHeaderSize:]
|
||||
tail, err := bsr.Block.bh.Unmarshal(bsr.Block.headerData)
|
||||
tail, err := bsr.Block.bh.Unmarshal(bsr.indexCursor[:marshaledBlockHeaderSize])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot parse block header read from index data at offset %d: %w", bsr.prevIndexBlockOffset(), err)
|
||||
}
|
||||
if len(tail) > 0 {
|
||||
return fmt.Errorf("non-empty tail left after parsing block header at offset %d: %x", bsr.prevIndexBlockOffset(), tail)
|
||||
}
|
||||
bsr.indexCursor = bsr.indexCursor[marshaledBlockHeaderSize:]
|
||||
|
||||
bsr.blocksCount++
|
||||
if bsr.blocksCount > bsr.ph.BlocksCount {
|
||||
|
Loading…
Reference in New Issue
Block a user