Skip to content

Commit

Permalink
Add back str sentinels
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Jan 20, 2024
1 parent b24c62d commit 6ca3c44
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rustc-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6ca3c44

Please sign in to comment.