1
Fork 0

Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk

A mish-mash of micro-optimizations

These were aimed at speeding up LLVM codegen, but ended up affecting other places as well.

r? `@bjorn3`
This commit is contained in:
bors 2023-06-30 00:35:19 +00:00
commit 8aed93d912
12 changed files with 32 additions and 117 deletions

View file

@ -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 {