@@ -56,6 +56,10 @@ impl Parser {
56
56
let size = self . read_varint ( ) ?;
57
57
self . tick = tick as i32 ;
58
58
59
+ if self . should_early_exit ( ) {
60
+ break ;
61
+ }
62
+
59
63
// Safety check
60
64
if self . ptr + size as usize >= self . bytes . get_len ( ) {
61
65
break ;
@@ -64,7 +68,7 @@ impl Parser {
64
68
let is_compressed = ( cmd & 64 ) == 64 ;
65
69
let demo_cmd = demo_cmd_type_from_int ( msg_type as i32 ) . unwrap ( ) ;
66
70
67
- // Early exit these for performance reasons
71
+ // skip these for performance reasons
68
72
if demo_cmd == DEM_Packet || demo_cmd == DEM_AnimationData {
69
73
self . ptr += size as usize ;
70
74
continue ;
@@ -126,6 +130,21 @@ impl Parser {
126
130
}
127
131
Ok ( self . combine_thread_outputs ( & mut ok) )
128
132
}
133
+ fn should_early_exit ( & self ) -> bool {
134
+ if self . only_header && !self . header . is_empty ( ) {
135
+ return true ;
136
+ }
137
+ if !self . wanted_ticks . is_empty ( ) {
138
+ // odd ticks in beginning of demo
139
+ if self . tick > 1000000 {
140
+ return false ;
141
+ }
142
+ if self . largest_wanted_tick < self . tick {
143
+ return true ;
144
+ }
145
+ }
146
+ false
147
+ }
129
148
// fn parse_stringtables_cmd(bytes: &[u8]) -> Result<(), DemoParserError> {}
130
149
pub fn create_parser_thread_input ( & self , offset : usize , parse_all : bool ) -> ParserThreadInput {
131
150
let cls_by_id = match & self . cls_by_id {
0 commit comments