Use partition_point
in SourceMap::lookup_source_file_idx
.
This makes it (a) a little simpler, and (b) more similar to `SourceFile::lookup_line`.
This commit is contained in:
parent
b4c6e19ade
commit
45fcd1d0c5
1 changed files with 1 additions and 5 deletions
|
@ -1072,11 +1072,7 @@ impl SourceMap {
|
|||
/// This index is guaranteed to be valid for the lifetime of this `SourceMap`,
|
||||
/// since `source_files` is a `MonotonicVec`
|
||||
pub fn lookup_source_file_idx(&self, pos: BytePos) -> usize {
|
||||
self.files
|
||||
.borrow()
|
||||
.source_files
|
||||
.binary_search_by_key(&pos, |key| key.start_pos)
|
||||
.unwrap_or_else(|p| p - 1)
|
||||
self.files.borrow().source_files.partition_point(|x| x.start_pos <= pos) - 1
|
||||
}
|
||||
|
||||
pub fn count_lines(&self) -> usize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue