Use CachingSourceMapView::byte_pos_to_line_and_col instead of SourceMap::lookup_char_pos
The former calculates byte offsets instead of char offsets. It is faster to calculate byte offsets than char offsets. Also most DWARF producers and consumers use byte offsets instead of char offsets.
This commit is contained in:
parent
33e73091f8
commit
eb4fc45310
2 changed files with 18 additions and 11 deletions
|
|
@ -3,6 +3,8 @@ mod line_info;
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
use rustc_span::CachingSourceMapView;
|
||||
|
||||
use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc};
|
||||
use cranelift_codegen::isa::RegUnit;
|
||||
use cranelift_codegen::ValueLocRange;
|
||||
|
|
@ -34,6 +36,8 @@ pub struct DebugContext<'tcx> {
|
|||
unit_range_list: RangeList,
|
||||
|
||||
types: HashMap<Ty<'tcx>, UnitEntryId>,
|
||||
|
||||
source_map: CachingSourceMapView<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> DebugContext<'tcx> {
|
||||
|
|
@ -98,6 +102,8 @@ impl<'tcx> DebugContext<'tcx> {
|
|||
unit_range_list: RangeList(Vec::new()),
|
||||
|
||||
types: HashMap::new(),
|
||||
|
||||
source_map: CachingSourceMapView::new(tcx.sess.source_map()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue