Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
export compressChunk method
Browse files Browse the repository at this point in the history
  • Loading branch information
upalinski committed Nov 10, 2023
1 parent e5ccd8a commit 958fb64
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bao.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func BaoEncode(dst io.WriterAt, data io.Reader, dataLen int64, outboard bool) ([
if err != nil {
return 0, [8]uint32{}
} else if bufLen <= ChunkSize {
cv := ChainingValue(compressChunk(read(chunkBuf[:bufLen]), &Iv, counter, flags))
cv := ChainingValue(CompressChunk(read(chunkBuf[:bufLen]), &Iv, counter, flags))
counter++
if !outboard {
write(chunkBuf[:bufLen], off)
Expand Down Expand Up @@ -105,7 +105,7 @@ func BaoDecode(dst io.Writer, data, outboard io.Reader, root [32]byte) (bool, er
if err != nil {
return false
} else if bufLen <= ChunkSize {
n := compressChunk(read(data, buf[:bufLen]), &Iv, counter, flags)
n := CompressChunk(read(data, buf[:bufLen]), &Iv, counter, flags)
counter++
return cv == ChainingValue(n)
}
Expand Down
2 changes: 1 addition & 1 deletion blake3.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func Sum512(b []byte) (out [64]byte) {
hashBlock(&out, b)
return
} else if len(b) <= ChunkSize {
n = compressChunk(b, &Iv, 0, 0)
n = CompressChunk(b, &Iv, 0, 0)
n.flags |= FlagRoot
} else {
h := *defaultHasher
Expand Down
6 changes: 3 additions & 3 deletions compress_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func compressBufferAVX512(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]ui
if buflen%ChunkSize != 0 {
// use non-asm for remainder
partialChunk := buf[buflen-buflen%ChunkSize : buflen]
cvs[numChunks] = ChainingValue(compressChunk(partialChunk, key, counter+numChunks, flags))
cvs[numChunks] = ChainingValue(CompressChunk(partialChunk, key, counter+numChunks, flags))
numChunks++
}
return mergeSubtrees(&cvs, numChunks, key, flags)
Expand All @@ -49,7 +49,7 @@ func compressBufferAVX2(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]uint
if buflen%ChunkSize != 0 {
// use non-asm for remainder
partialChunk := buf[buflen-buflen%ChunkSize : buflen]
cvs[numChunks] = ChainingValue(compressChunk(partialChunk, key, counter+numChunks, flags))
cvs[numChunks] = ChainingValue(CompressChunk(partialChunk, key, counter+numChunks, flags))
numChunks++
}
return mergeSubtrees(&cvs, numChunks, key, flags)
Expand All @@ -66,7 +66,7 @@ func compressBuffer(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]uint32,
}
}

func compressChunk(chunk []byte, key *[8]uint32, counter uint64, flags uint32) Node {
func CompressChunk(chunk []byte, key *[8]uint32, counter uint64, flags uint32) Node {
n := Node{
cv: *key,
counter: counter,
Expand Down
4 changes: 2 additions & 2 deletions compress_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ func ChainingValue(n Node) (cv [8]uint32) {

func compressBufferGeneric(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]uint32, counter uint64, flags uint32) (n Node) {
if buflen <= ChunkSize {
return compressChunk(buf[:buflen], key, counter, flags)
return CompressChunk(buf[:buflen], key, counter, flags)
}
var cvs [maxSIMD][8]uint32
var numCVs uint64
for bb := bytes.NewBuffer(buf[:buflen]); bb.Len() > 0; numCVs++ {
cvs[numCVs] = ChainingValue(compressChunk(bb.Next(ChunkSize), key, counter+numCVs, flags))
cvs[numCVs] = ChainingValue(CompressChunk(bb.Next(ChunkSize), key, counter+numCVs, flags))
}
return mergeSubtrees(&cvs, numCVs, key, flags)
}
Expand Down

0 comments on commit 958fb64

Please sign in to comment.