Skip to content

Commit

Permalink
Skip UTF-8 check temporarily to check perf
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Feb 2, 2025
1 parent b120ca9 commit 79a6cff
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2591,11 +2591,8 @@ impl StringArena {
let len = u32::from_ne_bytes(region[idx as usize..idx as usize + 4].try_into().unwrap());
let data = &region[idx as usize + 4..][..len as usize];

// SAFETY: We (in theory) could be passed a random `idx` into the memory region, so we need
// to re-check that the region is actually UTF-8 before returning. If it is, then it is safe
// to return &str, though it might not be a *useful* &str due to having near-random
// contents.
std::str::from_utf8(data).unwrap()
// FIXME: hopefully we got passed an accurate index.
unsafe { std::str::from_utf8_unchecked(data) }
}
}

Expand Down

0 comments on commit 79a6cff

Please sign in to comment.