From f7f6c813860b6f6b16d6862d95884b9b29b59bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 14 Feb 2025 12:35:54 +0900 Subject: [PATCH] Skip interning based on the text len --- crates/hstr/src/dynamic.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/hstr/src/dynamic.rs b/crates/hstr/src/dynamic.rs index 344a8238fbcc..54de15d80782 100644 --- a/crates/hstr/src/dynamic.rs +++ b/crates/hstr/src/dynamic.rs @@ -113,6 +113,14 @@ pub(crate) trait Storage { impl Storage for &'_ mut AtomStore { #[inline(never)] fn insert_entry(self, text: Cow, 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()