Skip to content

Commit

Permalink
Skip interning based on the text len
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Feb 14, 2025
1 parent 2bea793 commit f7f6c81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/hstr/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ pub(crate) trait Storage {
impl Storage for &'_ mut AtomStore {
#[inline(never)]
fn insert_entry(self, text: Cow<str>, hash: u64) -> Item {
// If the text is too long, interning is not worth it.
if text.len() > 512 {
return Item(ThinArc::from_header_and_slice(
HeaderWithLength::new(Metadata { hash }, text.len()),
text.as_bytes(),
));
}

let (entry, _) = self
.data
.raw_entry_mut()
Expand Down

0 comments on commit f7f6c81

Please sign in to comment.