From b7122efb9e2d4e1ff80dcf64f92751dc5d4924ef Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 8 Sep 2026 09:46:28 -0400 Subject: [PATCH] Delegate Name string comparisons to CharStr (#28401) Delegate `Name` equality with borrowed strings to `CharStr`, including Salsa lookups, so these callers use the compact string's comparison implementation. This connects Ruff's name comparisons to the short-string fast paths in https://github.com/astral-sh/char_str/pull/40. Those fast paths require a later `char_str` release; this change is compatible with the current dependency. --- crates/ruff_python_ast/src/name.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ruff_python_ast/src/name.rs b/crates/ruff_python_ast/src/name.rs index 585a9c88ed..5df673b54b 100644 --- a/crates/ruff_python_ast/src/name.rs +++ b/crates/ruff_python_ast/src/name.rs @@ -179,7 +179,7 @@ impl salsa::HashEqLike<&str> for Name { #[inline] fn eq(&self, data: &&str) -> bool { - self.as_str() == *data + self == *data } } @@ -261,7 +261,7 @@ impl std::fmt::Display for Name { impl PartialEq for Name { #[inline] fn eq(&self, other: &str) -> bool { - self.as_str() == other + self.0 == other } } @@ -275,7 +275,7 @@ impl PartialEq for str { impl PartialEq<&str> for Name { #[inline] fn eq(&self, other: &&str) -> bool { - self.as_str() == *other + self.0 == *other } } @@ -302,7 +302,7 @@ impl PartialEq for String { impl PartialEq<&String> for Name { #[inline] fn eq(&self, other: &&String) -> bool { - self.as_str() == *other + self == other.as_str() } }