cmd/ursrv, lib/scanner: Remove unnecessary slicing of slices (#7491)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
parent
e321bd3941
commit
0930bccf88
|
@ -89,7 +89,7 @@ var funcs = map[string]interface{}{
|
||||||
parts = append(parts, part)
|
parts = append(parts, part)
|
||||||
}
|
}
|
||||||
if len(input) > 0 {
|
if len(input) > 0 {
|
||||||
parts = append(parts, input[:])
|
parts = append(parts, input)
|
||||||
}
|
}
|
||||||
return parts[whichPart-1]
|
return parts[whichPart-1]
|
||||||
},
|
},
|
||||||
|
|
|
@ -195,17 +195,17 @@ func BenchmarkValidate(b *testing.B) {
|
||||||
for i := 0; i < blocksPerType; i++ {
|
for i := 0; i < blocksPerType; i++ {
|
||||||
var b block
|
var b block
|
||||||
b.data = make([]byte, 128<<10)
|
b.data = make([]byte, 128<<10)
|
||||||
r.Read(b.data[:])
|
r.Read(b.data)
|
||||||
b.hash = sha256.Sum256(b.data[:])
|
b.hash = sha256.Sum256(b.data)
|
||||||
b.weakhash = origAdler32.Checksum(b.data[:])
|
b.weakhash = origAdler32.Checksum(b.data)
|
||||||
blocks = append(blocks, b)
|
blocks = append(blocks, b)
|
||||||
}
|
}
|
||||||
// Blocks where the hash matches, but the weakhash doesn't.
|
// Blocks where the hash matches, but the weakhash doesn't.
|
||||||
for i := 0; i < blocksPerType; i++ {
|
for i := 0; i < blocksPerType; i++ {
|
||||||
var b block
|
var b block
|
||||||
b.data = make([]byte, 128<<10)
|
b.data = make([]byte, 128<<10)
|
||||||
r.Read(b.data[:])
|
r.Read(b.data)
|
||||||
b.hash = sha256.Sum256(b.data[:])
|
b.hash = sha256.Sum256(b.data)
|
||||||
b.weakhash = 1 // Zeros causes Validate to skip the weakhash.
|
b.weakhash = 1 // Zeros causes Validate to skip the weakhash.
|
||||||
blocks = append(blocks, b)
|
blocks = append(blocks, b)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ func BenchmarkValidate(b *testing.B) {
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
for _, b := range blocks {
|
for _, b := range blocks {
|
||||||
Validate(b.data[:], b.hash[:], b.weakhash)
|
Validate(b.data, b.hash[:], b.weakhash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue