Skip to content

Commit 71eb49c

Browse files
fmt
1 parent cae4a84 commit 71eb49c

File tree

1 file changed

+49
-42
lines changed

1 file changed

+49
-42
lines changed

compiler/rustc_span/src/analyze_source_file.rs

+49-42
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ pub fn analyze_source_file(
3535

3636
cfg_match! {
3737
cfg(any(target_arch = "x86", target_arch = "x86_64")) => {
38-
fn analyze_source_file_dispatch(src: &str,
39-
lines: &mut Vec<RelativeBytePos>,
40-
multi_byte_chars: &mut Vec<MultiByteChar>,
41-
non_narrow_chars: &mut Vec<NonNarrowChar>) {
38+
fn analyze_source_file_dispatch(
39+
src: &str,
40+
lines: &mut Vec<RelativeBytePos>,
41+
multi_byte_chars: &mut Vec<MultiByteChar>,
42+
non_narrow_chars: &mut Vec<NonNarrowChar>,
43+
) {
4244
if is_x86_feature_detected!("sse2") {
4345
unsafe {
44-
analyze_source_file_sse2(src,
45-
lines,
46-
multi_byte_chars,
47-
non_narrow_chars);
46+
analyze_source_file_sse2(src, lines, multi_byte_chars, non_narrow_chars);
4847
}
4948
} else {
50-
analyze_source_file_generic(src,
51-
src.len(),
52-
RelativeBytePos::from_u32(0),
53-
lines,
54-
multi_byte_chars,
55-
non_narrow_chars);
56-
49+
analyze_source_file_generic(
50+
src,
51+
src.len(),
52+
RelativeBytePos::from_u32(0),
53+
lines,
54+
multi_byte_chars,
55+
non_narrow_chars,
56+
);
5757
}
5858
}
5959

@@ -62,10 +62,12 @@ cfg_match! {
6262
/// function falls back to the generic implementation. Otherwise it uses
6363
/// SSE2 intrinsics to quickly find all newlines.
6464
#[target_feature(enable = "sse2")]
65-
unsafe fn analyze_source_file_sse2(src: &str,
66-
lines: &mut Vec<RelativeBytePos>,
67-
multi_byte_chars: &mut Vec<MultiByteChar>,
68-
non_narrow_chars: &mut Vec<NonNarrowChar>) {
65+
unsafe fn analyze_source_file_sse2(
66+
src: &str,
67+
lines: &mut Vec<RelativeBytePos>,
68+
multi_byte_chars: &mut Vec<MultiByteChar>,
69+
non_narrow_chars: &mut Vec<NonNarrowChar>,
70+
) {
6971
#[cfg(target_arch = "x86")]
7072
use std::arch::x86::*;
7173
#[cfg(target_arch = "x86_64")]
@@ -83,7 +85,7 @@ cfg_match! {
8385
// handled it.
8486
let mut intra_chunk_offset = 0;
8587

86-
for chunk_index in 0 .. chunk_count {
88+
for chunk_index in 0..chunk_count {
8789
let ptr = src_bytes.as_ptr() as *const __m128i;
8890
// We don't know if the pointer is aligned to 16 bytes, so we
8991
// use `loadu`, which supports unaligned loading.
@@ -126,7 +128,7 @@ cfg_match! {
126128

127129
if index >= CHUNK_SIZE as u32 {
128130
// We have arrived at the end of the chunk.
129-
break
131+
break;
130132
}
131133

132134
lines.push(RelativeBytePos(index) + output_offset);
@@ -137,58 +139,63 @@ cfg_match! {
137139

138140
// We are done for this chunk. All control characters were
139141
// newlines and we took care of those.
140-
continue
142+
continue;
141143
} else {
142144
// Some of the control characters are not newlines,
143145
// fall through to the slow path below.
144146
}
145147
} else {
146148
// No control characters, nothing to record for this chunk
147-
continue
149+
continue;
148150
}
149151
}
150152

151153
// The slow path.
152154
// There are control chars in here, fallback to generic decoding.
153155
let scan_start = chunk_index * CHUNK_SIZE + intra_chunk_offset;
154156
intra_chunk_offset = analyze_source_file_generic(
155-
&src[scan_start .. ],
157+
&src[scan_start..],
156158
CHUNK_SIZE - intra_chunk_offset,
157159
RelativeBytePos::from_usize(scan_start),
158160
lines,
159161
multi_byte_chars,
160-
non_narrow_chars
162+
non_narrow_chars,
161163
);
162164
}
163165

164166
// There might still be a tail left to analyze
165167
let tail_start = chunk_count * CHUNK_SIZE + intra_chunk_offset;
166168
if tail_start < src.len() {
167-
analyze_source_file_generic(&src[tail_start ..],
168-
src.len() - tail_start,
169-
RelativeBytePos::from_usize(tail_start),
170-
lines,
171-
multi_byte_chars,
172-
non_narrow_chars);
169+
analyze_source_file_generic(
170+
&src[tail_start..],
171+
src.len() - tail_start,
172+
RelativeBytePos::from_usize(tail_start),
173+
lines,
174+
multi_byte_chars,
175+
non_narrow_chars,
176+
);
173177
}
174178
}
175179
}
176180
_ => {
177181
// The target (or compiler version) does not support SSE2 ...
178-
fn analyze_source_file_dispatch(src: &str,
179-
lines: &mut Vec<RelativeBytePos>,
180-
multi_byte_chars: &mut Vec<MultiByteChar>,
181-
non_narrow_chars: &mut Vec<NonNarrowChar>) {
182-
analyze_source_file_generic(src,
183-
src.len(),
184-
RelativeBytePos::from_u32(0),
185-
lines,
186-
multi_byte_chars,
187-
non_narrow_chars);
182+
fn analyze_source_file_dispatch(
183+
src: &str,
184+
lines: &mut Vec<RelativeBytePos>,
185+
multi_byte_chars: &mut Vec<MultiByteChar>,
186+
non_narrow_chars: &mut Vec<NonNarrowChar>,
187+
) {
188+
analyze_source_file_generic(
189+
src,
190+
src.len(),
191+
RelativeBytePos::from_u32(0),
192+
lines,
193+
multi_byte_chars,
194+
non_narrow_chars,
195+
);
188196
}
189197
}
190198
}
191-
192199
// `scan_len` determines the number of bytes in `src` to scan. Note that the
193200
// function can read past `scan_len` if a multi-byte character start within the
194201
// range but extends past it. The overflow is returned by the function.

0 commit comments

Comments
 (0)