about summary refs log tree commit diff
path: root/src/debuginfo
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-06-28 08:14:29 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2023-06-29 11:26:39 +1000
commit9db001dfbb79107de53bb187f388f7dd1f711413 (patch)
tree743afbfdfdb801d577459b3173e86effbbe0631d /src/debuginfo
parent7ba31b9938833726cfcd8927a9f9c95f43c1b279 (diff)
downloadrust-9db001dfbb79107de53bb187f388f7dd1f711413.tar.gz
rust-9db001dfbb79107de53bb187f388f7dd1f711413.zip
Avoid unnecessary line lookup.
`lookup_debug_loc` calls `SourceMap::lookup_line`, which does a binary
search over the files, and then a binary search over the lines within
the found file. It then calls `SourceFile::line_begin_pos`, which redoes
the binary search over the lines within the found file.

This commit removes the second binary search over the lines, instead
getting the line starting pos directly using the result of the first
binary search over the lines.

(And likewise for `get_span_loc`, in the cranelift backend.)
Diffstat (limited to 'src/debuginfo')
-rw-r--r--src/debuginfo/line_info.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs
index 463de6a91c7..1b454b6667c 100644
--- a/src/debuginfo/line_info.rs
+++ b/src/debuginfo/line_info.rs
@@ -81,7 +81,7 @@ impl DebugContext {
 
         match tcx.sess.source_map().lookup_line(span.lo()) {
             Ok(SourceFileAndLine { sf: file, line }) => {
-                let line_pos = file.line_begin_pos(span.lo());
+                let line_pos = file.lines(|lines| lines[line]);
 
                 (
                     file,