Skip to content

Commit 9db001d

Browse files
committed
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.)
1 parent 7ba31b9 commit 9db001d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/debuginfo/line_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl DebugContext {
8181

8282
match tcx.sess.source_map().lookup_line(span.lo()) {
8383
Ok(SourceFileAndLine { sf: file, line }) => {
84-
let line_pos = file.line_begin_pos(span.lo());
84+
let line_pos = file.lines(|lines| lines[line]);
8585

8686
(
8787
file,

0 commit comments

Comments
 (0)