about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-06-28 10:37:43 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2023-06-29 11:36:09 +1000
commit45fcd1d0c5df8287a3ffe620fa41b4ab478bc323 (patch)
tree3a94b7ab10c38d27e6878331a0b1e7438659be12 /compiler/rustc_span/src
parentb4c6e19adeffad05e6039c21fdbda2097f3a2485 (diff)
downloadrust-45fcd1d0c5df8287a3ffe620fa41b4ab478bc323.tar.gz
rust-45fcd1d0c5df8287a3ffe620fa41b4ab478bc323.zip
Use `partition_point` in `SourceMap::lookup_source_file_idx`.
This makes it (a) a little simpler, and (b) more similar to
`SourceFile::lookup_line`.
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/source_map.rs6
1 files changed, 1 insertions, 5 deletions
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs
index c53fe084c4d..86716da1712 100644
--- a/compiler/rustc_span/src/source_map.rs
+++ b/compiler/rustc_span/src/source_map.rs
@@ -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 {