@@ -129,97 +129,97 @@ pub fn extract<'i, I: IndexData + 'i>(
129
129
continue ;
130
130
}
131
131
132
- if let State :: Ignoring ( a) = state {
133
- if a. find ( lines[ i] . line . sanitized ( ) ) . is_some ( ) {
134
- state = State :: SearchingSectionStart ;
135
- }
136
-
137
- i += 1 ;
138
- continue ;
139
- }
140
-
141
- if let State :: SearchingSectionStart = state {
142
- if lines[ i] . score > config. block_separator_max_score {
143
- state = State :: SearchingOutlier ;
144
- section_start = i;
145
- } else {
146
- if trailing_context > 0 {
147
- trailing_context -= 1 ;
148
- blocks. last_mut ( ) . unwrap ( ) . push ( lines[ i] . line ) ;
149
- prev_section_end = i;
132
+ match state {
133
+ State :: Ignoring ( a) => {
134
+ if a. find ( lines[ i] . line . sanitized ( ) ) . is_some ( ) {
135
+ state = State :: SearchingSectionStart ;
150
136
}
151
137
152
138
i += 1 ;
153
139
continue ;
154
140
}
155
- }
156
141
157
- if let State :: SearchingOutlier = state {
158
- if lines[ i] . score <= config. block_separator_max_score {
159
- if trailing_context > 0 {
160
- trailing_context -= 1 ;
161
- blocks. last_mut ( ) . unwrap ( ) . push ( lines[ i] . line ) ;
162
- prev_section_end = i;
163
- }
142
+ State :: SearchingSectionStart => {
143
+ if lines[ i] . score > config. block_separator_max_score {
144
+ state = State :: SearchingOutlier ;
145
+ section_start = i;
146
+ } else {
147
+ if trailing_context > 0 {
148
+ trailing_context -= 1 ;
149
+ blocks. last_mut ( ) . unwrap ( ) . push ( lines[ i] . line ) ;
150
+ prev_section_end = i;
151
+ }
164
152
165
- state = State :: SearchingSectionStart ;
166
- i += 1 ;
167
- continue ;
153
+ i += 1 ;
154
+ continue ;
155
+ }
168
156
}
169
157
170
- if lines[ i] . score >= config. unique_line_min_score {
171
- trailing_context = 0 ;
158
+ State :: SearchingOutlier => {
159
+ if lines[ i] . score <= config. block_separator_max_score {
160
+ if trailing_context > 0 {
161
+ trailing_context -= 1 ;
162
+ blocks. last_mut ( ) . unwrap ( ) . push ( lines[ i] . line ) ;
163
+ prev_section_end = i;
164
+ }
165
+
166
+ state = State :: SearchingSectionStart ;
167
+ i += 1 ;
168
+ continue ;
169
+ }
172
170
173
- let start_printing;
171
+ if lines[ i] . score >= config. unique_line_min_score {
172
+ trailing_context = 0 ;
174
173
175
- if prev_section_end + config. block_merge_distance >= section_start {
176
- if !blocks. is_empty ( ) {
177
- let last_idx = blocks. len ( ) - 1 ;
178
- active_block = blocks. remove ( last_idx) ;
174
+ let start_printing;
175
+
176
+ if prev_section_end + config. block_merge_distance >= section_start {
177
+ if !blocks. is_empty ( ) {
178
+ let last_idx = blocks. len ( ) - 1 ;
179
+ active_block = blocks. remove ( last_idx) ;
180
+ }
181
+ start_printing = prev_section_end;
182
+ } else {
183
+ start_printing = section_start. saturating_sub ( config. context_lines ) ;
179
184
}
180
- start_printing = prev_section_end;
185
+
186
+ for j in start_printing..i {
187
+ active_block. push ( lines[ j] . line ) ;
188
+ }
189
+
190
+ state = State :: Printing ;
181
191
} else {
182
- start_printing = section_start. saturating_sub ( config. context_lines ) ;
183
- }
192
+ if trailing_context > 0 {
193
+ trailing_context -= 1 ;
194
+ blocks. last_mut ( ) . unwrap ( ) . push ( lines[ i] . line ) ;
195
+ prev_section_end = i;
196
+
197
+ // No need to update section_start since we'll trigger the `merge` case above
198
+ // anyway (prev_section_end >= section_start).
199
+ }
184
200
185
- for j in start_printing..i {
186
- active_block . push ( lines [ j ] . line ) ;
201
+ i += 1 ;
202
+ continue ;
187
203
}
204
+ }
188
205
189
- state = State :: Printing ;
190
- } else {
191
- if trailing_context > 0 {
192
- trailing_context -= 1 ;
193
- blocks . last_mut ( ) . unwrap ( ) . push ( lines [ i ] . line ) ;
206
+ State :: Printing => {
207
+ if lines [ i ] . score <= config . block_separator_max_score {
208
+ if !active_block . is_empty ( ) {
209
+ blocks . push ( mem :: replace ( & mut active_block , vec ! [ ] ) ) ;
210
+ }
194
211
prev_section_end = i;
212
+ state = State :: SearchingSectionStart ;
195
213
196
- // No need to update section_start since we'll trigger the `merge` case above
197
- // anyway (prev_section_end >= section_start).
214
+ trailing_context = config. context_lines ;
215
+ } else {
216
+ active_block. push ( lines[ i] . line ) ;
198
217
}
199
218
200
219
i += 1 ;
201
220
continue ;
202
221
}
203
222
}
204
-
205
- if let State :: Printing = state {
206
- if lines[ i] . score <= config. block_separator_max_score {
207
- if !active_block. is_empty ( ) {
208
- blocks. push ( mem:: replace ( & mut active_block, vec ! [ ] ) ) ;
209
- }
210
- prev_section_end = i;
211
- state = State :: SearchingSectionStart ;
212
-
213
- trailing_context = config. context_lines ;
214
- } else {
215
- active_block. push ( lines[ i] . line ) ;
216
- }
217
-
218
- i += 1 ;
219
- continue ;
220
- }
221
-
222
- unreachable ! ( ) ;
223
223
}
224
224
225
225
if !active_block. is_empty ( ) {
0 commit comments