raft/tracker: remove unused Inflights.FreeFirstOne

Signed-off-by: Pavel Kalinnikov <pavel@cockroachlabs.com>
This commit is contained in:
Pavel Kalinnikov 2022-10-27 00:22:07 +01:00
parent 4969aa81ae
commit 467114ed87
2 changed files with 14 additions and 25 deletions

View File

@ -113,10 +113,6 @@ func (in *Inflights) FreeLE(to uint64) {
}
}
// FreeFirstOne releases the first inflight. This is a no-op if nothing is
// inflight.
func (in *Inflights) FreeFirstOne() { in.FreeLE(in.buffer[in.start]) }
// Full returns true if no more messages can be sent at the moment.
func (in *Inflights) Full() bool {
return in.count == in.size

View File

@ -105,6 +105,20 @@ func TestInflightFreeTo(t *testing.T) {
in.Add(uint64(i))
}
in.FreeLE(0)
wantIn0 := &Inflights{
start: 1,
count: 9,
size: 10,
// ↓------------------------
buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
}
if !reflect.DeepEqual(in, wantIn0) {
t.Fatalf("in = %+v, want %+v", in, wantIn0)
}
in.FreeLE(4)
wantIn := &Inflights{
@ -166,24 +180,3 @@ func TestInflightFreeTo(t *testing.T) {
t.Fatalf("in = %+v, want %+v", in, wantIn4)
}
}
func TestInflightFreeFirstOne(t *testing.T) {
in := NewInflights(10)
for i := 0; i < 10; i++ {
in.Add(uint64(i))
}
in.FreeFirstOne()
wantIn := &Inflights{
start: 1,
count: 9,
size: 10,
// ↓------------------------
buffer: []uint64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
}
if !reflect.DeepEqual(in, wantIn) {
t.Fatalf("in = %+v, want %+v", in, wantIn)
}
}