@@ -110,25 +110,19 @@ cfg_match! {
110
110
if control_char_mask != 0 {
111
111
// Check for newlines in the chunk
112
112
let newlines_test = unsafe { _mm_cmpeq_epi8( chunk, _mm_set1_epi8( b'\n' as i8 ) ) } ;
113
- let newlines_mask = unsafe { _mm_movemask_epi8( newlines_test) } ;
113
+ let mut newlines_mask = unsafe { _mm_movemask_epi8( newlines_test) } ;
114
114
115
115
if control_char_mask == newlines_mask {
116
116
// All control characters are newlines, record them
117
- let mut newlines_mask = 0xFFFF0000 | newlines_mask as u32 ;
118
117
let output_offset = RelativeBytePos :: from_usize( chunk_index * CHUNK_SIZE + 1 ) ;
119
118
120
- loop {
119
+ while newlines_mask != 0 {
121
120
let index = newlines_mask. trailing_zeros( ) ;
122
121
123
- if index >= CHUNK_SIZE as u32 {
124
- // We have arrived at the end of the chunk.
125
- break ;
126
- }
127
-
128
122
lines. push( RelativeBytePos ( index) + output_offset) ;
129
123
130
124
// Clear the bit, so we can find the next one.
131
- newlines_mask &= ( ! 1 ) << index ;
125
+ newlines_mask &= newlines_mask - 1 ;
132
126
}
133
127
134
128
// We are done for this chunk. All control characters were
@@ -268,25 +262,19 @@ cfg_match! {
268
262
if control_char_mask != 0 {
269
263
// Check for newlines in the chunk
270
264
let newlines_test = unsafe { _mm_cmpeq_epi8( chunk, _mm_set1_epi8( b'\n' as i8 ) ) } ;
271
- let newlines_mask = unsafe { _mm_movemask_epi8( newlines_test) } ;
265
+ let mut newlines_mask = unsafe { _mm_movemask_epi8( newlines_test) } ;
272
266
273
267
if control_char_mask == newlines_mask {
274
268
// All control characters are newlines, record them
275
- let mut newlines_mask = 0xFFFF0000 | newlines_mask as u32 ;
276
269
let output_offset = RelativeBytePos :: from_usize( chunk_index * CHUNK_SIZE + 1 ) ;
277
270
278
- loop {
271
+ while newlines_mask != 0 {
279
272
let index = newlines_mask. trailing_zeros( ) ;
280
273
281
- if index >= CHUNK_SIZE as u32 {
282
- // We have arrived at the end of the chunk.
283
- break ;
284
- }
285
-
286
274
lines. push( RelativeBytePos ( index) + output_offset) ;
287
275
288
276
// Clear the bit, so we can find the next one.
289
- newlines_mask &= ( ! 1 ) << index ;
277
+ newlines_mask &= newlines_mask - 1 ;
290
278
}
291
279
292
280
// We are done for this chunk. All control characters were
0 commit comments