Skip to content

Commit 45fcd1d

Browse files
committed
Use partition_point in SourceMap::lookup_source_file_idx.
This makes it (a) a little simpler, and (b) more similar to `SourceFile::lookup_line`.
1 parent b4c6e19 commit 45fcd1d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

compiler/rustc_span/src/source_map.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,11 +1072,7 @@ impl SourceMap {
10721072
/// This index is guaranteed to be valid for the lifetime of this `SourceMap`,
10731073
/// since `source_files` is a `MonotonicVec`
10741074
pub fn lookup_source_file_idx(&self, pos: BytePos) -> usize {
1075-
self.files
1076-
.borrow()
1077-
.source_files
1078-
.binary_search_by_key(&pos, |key| key.start_pos)
1079-
.unwrap_or_else(|p| p - 1)
1075+
self.files.borrow().source_files.partition_point(|x| x.start_pos <= pos) - 1
10801076
}
10811077

10821078
pub fn count_lines(&self) -> usize {

0 commit comments

Comments
 (0)