From 6ca3c44af89ac5f4319a64e7c1d65824779b0a59 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 19 Jan 2024 19:59:04 -0500 Subject: [PATCH] Add back str sentinels --- rustc-hash/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rustc-hash/src/lib.rs b/rustc-hash/src/lib.rs index d043182e0333e..cf5ad0da4f15f 100644 --- a/rustc-hash/src/lib.rs +++ b/rustc-hash/src/lib.rs @@ -165,10 +165,12 @@ impl Hasher for FxHasher { self.add_to_hash(i); } - // Avoid hashing 0xFF sentinel; we don't need prefix-free hashes. #[inline] fn write_str(&mut self, s: &str) { self.write(s.as_bytes()); + // FIXME: Not having this seems to add significant cost to Symbol::intern(?), but it's not + // very clear why. That's interning &str, so it's not obvious why this matters. + self.write_u8(0xFF); } // Avoid hashing length prefixes. For our purposes the actual data gives us plenty of entropy