diff --git a/transport/internet/kcp/receiving.go b/transport/internet/kcp/receiving.go index f3bbc8c73..a86f24597 100644 --- a/transport/internet/kcp/receiving.go +++ b/transport/internet/kcp/receiving.go @@ -33,9 +33,6 @@ func (this *ReceivingWindow) Set(idx uint32, value *Segment) bool { func (this *ReceivingWindow) Remove(idx uint32) *Segment { pos := this.Position(idx) - if this.list[pos] == nil { - return nil - } e := this.list[pos] this.list[pos] = nil return e diff --git a/transport/internet/kcp/receiving_test.go b/transport/internet/kcp/receiving_test.go index ef2a6e72f..bc060ce5d 100644 --- a/transport/internet/kcp/receiving_test.go +++ b/transport/internet/kcp/receiving_test.go @@ -19,6 +19,10 @@ func TestRecivingWindow(t *testing.T) { assert.Bool(window.Set(0, seg0)).IsTrue() assert.Pointer(window.RemoveFirst()).Equals(seg0) + e := window.RemoveFirst() + if e != nil { + assert.Fail("Expecting nil.") + } assert.Bool(window.Set(1, seg1)).IsTrue() assert.Bool(window.Set(2, seg2)).IsTrue()