File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 44 "errors"
55 "fmt"
66 "io"
7+ "math"
78 "sync"
89 "time"
910
@@ -62,14 +63,26 @@ func (p *Parser) ParseHeader() (common.DemoHeader, error) {
6263 // Initialize queue if the buffer size wasn't specified, the amount of ticks
6364 // seems to be a good indicator of how many events we'll get
6465 if p .msgQueue == nil {
65- p .initMsgQueue (h .PlaybackTicks )
66+ p .initMsgQueue (msgQueueSize ( h .PlaybackTicks ) )
6667 }
6768
6869 p .header = & h
6970
7071 return h , nil
7172}
7273
74+ func msgQueueSize (ticks int ) int {
75+ const (
76+ msgQueueMinSize = 50000
77+ msgQueueMaxSize = 500000
78+ )
79+
80+ size := math .Max (msgQueueMinSize , float64 (ticks ))
81+ size = math .Min (msgQueueMaxSize , size )
82+
83+ return int (size )
84+ }
85+
7386// ParseToEnd attempts to parse the demo until the end.
7487// Aborts and returns ErrCancelled if Cancel() is called before the end.
7588//
You can’t perform that action at this time.
0 commit comments