Skip to content

Commit 79a6cff

Browse files
Skip UTF-8 check temporarily to check perf
1 parent b120ca9 commit 79a6cff

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

‎compiler/rustc_span/src/symbol.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,11 +2591,8 @@ impl StringArena {
25912591
let len = u32::from_ne_bytes(region[idx as usize..idx as usize + 4].try_into().unwrap());
25922592
let data = &region[idx as usize + 4..][..len as usize];
25932593

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

0 commit comments

Comments
 (0)