mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 10:45:37 +08:00
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.
This commit is contained in:
1 parent
12132db288
commit
b7122efb9e
1 file changed
+4
-4
@@ -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<str> for Name {
|
||||
#[inline]
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
self.as_str() == other
|
||||
self.0 == other
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ impl PartialEq<Name> 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<Name> for String {
|
||||
impl PartialEq<&String> for Name {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&String) -> bool {
|
||||
self.as_str() == *other
|
||||
self == other.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user