Skip to content

Commit a843730

Browse files
committed
Simplify span_data_to_lines_and_cols.
1 parent 6c15339 commit a843730

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

compiler/rustc_span/src/caching_source_map_view.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,25 @@ impl<'sm> CachingSourceMapView<'sm> {
123123

124124
if lo_cache_idx != -1 && hi_cache_idx != -1 {
125125
// Cache hit for span lo and hi. Check if they belong to the same file.
126-
let result = {
127-
let lo = &self.line_cache[lo_cache_idx as usize];
128-
let hi = &self.line_cache[hi_cache_idx as usize];
126+
let lo_file_index = self.line_cache[lo_cache_idx as usize].file_index;
127+
let hi_file_index = self.line_cache[hi_cache_idx as usize].file_index;
129128

130-
if lo.file_index != hi.file_index {
131-
return None;
132-
}
133-
134-
(
135-
lo.file.stable_id,
136-
lo.line_number,
137-
span_data.lo - lo.line.start,
138-
hi.line_number,
139-
span_data.hi - hi.line.start,
140-
)
141-
};
129+
if lo_file_index != hi_file_index {
130+
return None;
131+
}
142132

143133
self.line_cache[lo_cache_idx as usize].touch(self.time_stamp);
144134
self.line_cache[hi_cache_idx as usize].touch(self.time_stamp);
145135

146-
return Some(result);
136+
let lo = &self.line_cache[lo_cache_idx as usize];
137+
let hi = &self.line_cache[hi_cache_idx as usize];
138+
return Some((
139+
lo.file.stable_id,
140+
lo.line_number,
141+
span_data.lo - lo.line.start,
142+
hi.line_number,
143+
span_data.hi - hi.line.start,
144+
));
147145
}
148146

149147
// No cache hit or cache hit for only one of span lo and hi.

0 commit comments

Comments
 (0)