Minor updates on ringbuffer and formatting.

This commit is contained in:
genxium
2022-12-02 10:20:58 +08:00
parent 3b0db64792
commit 0373665382
3 changed files with 5 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ func NewRingBuffer(n int32) *RingBuffer {
}
func (rb *RingBuffer) Put(pItem interface{}) {
for rb.Cnt >= rb.N-1 {
for 0 < rb.Cnt && rb.Cnt >= rb.N {
// Make room for the new element
rb.Pop()
}
@@ -78,7 +78,7 @@ func (rb *RingBuffer) GetByOffset(offsetFromSt int32) interface{} {
}
func (rb *RingBuffer) GetByFrameId(frameId int32) interface{} {
if frameId >= rb.EdFrameId {
if frameId >= rb.EdFrameId || frameId < rb.StFrameId {
return nil
}
return rb.GetByOffset(frameId - rb.StFrameId)