Skip to content

Commit e08e60c

Browse files
committed
Does this fix the prefect changes? Is this still a perf improvement?
1 parent 1463ce5 commit e08e60c

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

crates/ty_python_semantic/src/types.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14109,12 +14109,18 @@ impl<'db> UnionType<'db> {
1410914109

1411014110
pub(crate) fn filter(self, db: &'db dyn Db, f: impl FnMut(&Type<'db>) -> bool) -> Type<'db> {
1411114111
let current = self.elements(db);
14112-
let new: Box<[Type<'db>]> = current.iter().copied().filter(f).collect();
14112+
let new: Vec<Type<'db>> = current.iter().copied().filter(f).collect();
1411314113
match new.len() {
1411414114
0 => Type::Never,
1411514115
1 => new[0],
1411614116
len if len == current.len() => Type::Union(self),
14117-
_ => Type::Union(UnionType::new(db, new, self.recursively_defined(db))),
14117+
_ => new
14118+
.iter()
14119+
.fold(UnionBuilder::new(db), |builder, element| {
14120+
builder.add(*element)
14121+
})
14122+
.recursively_defined(self.recursively_defined(db))
14123+
.build(),
1411814124
}
1411914125
}
1412014126

0 commit comments

Comments
 (0)