mirror of https://bitbucket.org/ausocean/av.git
codec-util: removed newticker helper
This commit is contained in:
parent
8518d931c6
commit
e63b51e24f
|
@ -48,13 +48,6 @@ func init() {
|
|||
close(zeroTicks)
|
||||
}
|
||||
|
||||
func newTicker(d time.Duration) *time.Ticker {
|
||||
if d == 0 {
|
||||
return &time.Ticker{C: zeroTicks}
|
||||
}
|
||||
return time.NewTicker(d)
|
||||
}
|
||||
|
||||
// Lex reads *l.bufSize bytes from src and writes them to dst every d seconds.
|
||||
func (l *ByteLexer) Lex(dst io.Writer, src io.Reader, d time.Duration) error {
|
||||
if l.bufSize == nil {
|
||||
|
@ -68,7 +61,14 @@ func (l *ByteLexer) Lex(dst io.Writer, src io.Reader, d time.Duration) error {
|
|||
return fmt.Errorf("invalid delay: %v", d)
|
||||
}
|
||||
|
||||
ticker := newTicker(d)
|
||||
var ticker *time.Ticker
|
||||
if d == 0 {
|
||||
ticker = &time.Ticker{C: zeroTicks}
|
||||
} else {
|
||||
ticker = time.NewTicker(d)
|
||||
defer ticker.Stop()
|
||||
}
|
||||
|
||||
buf := make([]byte, bufSize)
|
||||
for {
|
||||
<-ticker.C
|
||||
|
|
Loading…
Reference in New Issue