mirror of
https://github.com/lkmio/lkm.git
synced 2025-10-05 15:16:49 +08:00
使用gop缓存
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package stream
|
||||
|
||||
import "github.com/yangjiechina/avformat/utils"
|
||||
import (
|
||||
"github.com/yangjiechina/avformat/utils"
|
||||
)
|
||||
|
||||
type RingBuffer interface {
|
||||
IsEmpty() bool
|
||||
@@ -64,6 +66,7 @@ func (r *ringBuffer) Pop() interface{} {
|
||||
}
|
||||
|
||||
element := r.data[r.head]
|
||||
r.data[r.head] = nil
|
||||
r.head = (r.head + 1) % cap(r.data)
|
||||
r.size--
|
||||
return element
|
||||
@@ -86,7 +89,7 @@ func (r *ringBuffer) All() ([]interface{}, []interface{}) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if r.head < r.tail {
|
||||
if r.head <= r.tail {
|
||||
return r.data[r.head:], r.data[:r.tail]
|
||||
} else {
|
||||
return r.data[r.head:], nil
|
||||
|
Reference in New Issue
Block a user