Rollup merge of #69434 - petrochenkov:metabs, r=Mark-Simulacrum
rustc_metadata: Use binary search from standard library instead of a hand rolled one. Noticed while reviewing https://github.com/rust-lang/rust/pull/68941.
This commit is contained in:
commit
c0760279b3
@ -408,20 +408,12 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
|
||||
{
|
||||
last_source_file
|
||||
} else {
|
||||
let mut a = 0;
|
||||
let mut b = imported_source_files.len();
|
||||
let index = imported_source_files
|
||||
.binary_search_by_key(&lo, |source_file| source_file.original_start_pos)
|
||||
.unwrap_or_else(|index| index - 1);
|
||||
|
||||
while b - a > 1 {
|
||||
let m = (a + b) / 2;
|
||||
if imported_source_files[m].original_start_pos > lo {
|
||||
b = m;
|
||||
} else {
|
||||
a = m;
|
||||
}
|
||||
}
|
||||
|
||||
self.last_source_file_index = a;
|
||||
&imported_source_files[a]
|
||||
self.last_source_file_index = index;
|
||||
&imported_source_files[index]
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user