clean up
This commit is contained in:
parent
5b6a4ff114
commit
a36687c5b2
@ -95,10 +95,7 @@ func (rq *RetransmitQueue) GetExpired() []*RetransmitEntry {
|
||||
|
||||
// calculateTimeout computes timeout with exponential backoff
|
||||
func (rq *RetransmitQueue) calculateTimeout(attempts int) time.Duration {
|
||||
timeout := rq.baseTimeout * time.Duration(attempts*attempts) // Quadratic backoff
|
||||
if timeout > rq.maxTimeout {
|
||||
timeout = rq.maxTimeout
|
||||
}
|
||||
timeout := min(rq.baseTimeout*time.Duration(attempts*attempts), rq.maxTimeout) // Quadratic backoff
|
||||
return timeout
|
||||
}
|
||||
|
||||
@ -169,10 +166,7 @@ func (fm *FragmentManager) FragmentPacket(data []byte, startSeq uint16) []*Proto
|
||||
seq := startSeq
|
||||
|
||||
for offset := 0; offset < len(data); offset += chunkSize {
|
||||
end := offset + chunkSize
|
||||
if end > len(data) {
|
||||
end = len(data)
|
||||
}
|
||||
end := min(offset+chunkSize, len(data))
|
||||
|
||||
var fragmentData []byte
|
||||
if offset == 0 {
|
||||
|
@ -390,8 +390,7 @@ func BenchmarkCRC(b *testing.B) {
|
||||
data[i] = byte(i)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for range b.N {
|
||||
for b.Loop() {
|
||||
CalculateCRC32(data)
|
||||
}
|
||||
}
|
||||
@ -403,8 +402,7 @@ func BenchmarkCompression(b *testing.B) {
|
||||
data[i] = byte(i % 256)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for range b.N {
|
||||
for b.Loop() {
|
||||
compressed, _ := Compress(data)
|
||||
Decompress(compressed)
|
||||
}
|
||||
@ -420,8 +418,7 @@ func BenchmarkEncryption(b *testing.B) {
|
||||
data[i] = byte(i)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for range b.N {
|
||||
for b.Loop() {
|
||||
encrypted := crypto.Encrypt(data)
|
||||
crypto.Decrypt(encrypted)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user