contentenc: MergeBlocks: short-circuit the trivial case
Saves 3% for the tar extract benchmark because we skip the allocation.
This commit is contained in:
parent
52ab0462a4
commit
b6bda01c33
@ -277,6 +277,10 @@ func (be *ContentEnc) doEncryptBlock(plaintext []byte, blockNo uint64, fileID []
|
||||
// MergeBlocks - Merge newData into oldData at offset
|
||||
// New block may be bigger than both newData and oldData
|
||||
func (be *ContentEnc) MergeBlocks(oldData []byte, newData []byte, offset int) []byte {
|
||||
// Fastpath for small-file creation
|
||||
if len(oldData) == 0 && offset == 0 {
|
||||
return newData
|
||||
}
|
||||
|
||||
// Make block of maximum size
|
||||
out := make([]byte, be.plainBS)
|
||||
|
Loading…
Reference in New Issue
Block a user