[ty] Use upstream GetSize implementation for OrderMap and OrderSet (#22374)

This commit is contained in:
Micha Reiser
2026-01-04 20:54:03 +01:00
committed by GitHub
parent 46a4bfc478
commit b85c0190c5
6 changed files with 3 additions and 29 deletions

View File

@@ -14364,7 +14364,7 @@ impl KnownUnion {
}
}
#[salsa::interned(debug, heap_size=IntersectionType::heap_size)]
#[salsa::interned(debug, heap_size=ruff_memory_usage::heap_size)]
pub struct IntersectionType<'db> {
/// The intersection type includes only values in all of these types.
#[returns(ref)]
@@ -14653,11 +14653,6 @@ impl<'db> IntersectionType<'db> {
pub(crate) fn is_simple_negation(self, db: &'db dyn Db) -> bool {
self.positive(db).is_empty() && self.negative(db).len() == 1
}
fn heap_size((positive, negative): &(FxOrderSet<Type<'db>>, FxOrderSet<Type<'db>>)) -> usize {
ruff_memory_usage::order_set_heap_size(positive)
+ ruff_memory_usage::order_set_heap_size(negative)
}
}
/// # Ordering

View File

@@ -202,7 +202,7 @@ impl<'a, 'db> InferableTypeVars<'a, 'db> {
/// # Ordering
/// Ordering is based on the context's salsa-assigned id and not on its values.
/// The id may change between runs, or when the context was garbage collected and recreated.
#[salsa::interned(debug, constructor=new_internal, heap_size=GenericContext::heap_size)]
#[salsa::interned(debug, constructor=new_internal, heap_size=ruff_memory_usage::heap_size)]
#[derive(PartialOrd, Ord)]
pub struct GenericContext<'db> {
#[returns(ref)]
@@ -689,12 +689,6 @@ impl<'db> GenericContext<'db> {
Self::from_typevar_instances(db, variables)
}
fn heap_size(
(variables,): &(FxOrderMap<BoundTypeVarIdentity<'db>, BoundTypeVarInstance<'db>>,),
) -> usize {
ruff_memory_usage::order_map_heap_size(variables)
}
}
fn inferable_typevars_cycle_initial<'db>(