Skip to content

Commit 6045edf

Browse files
committed
Auto merge of #162531 - khyperia:abby-perf, r=<try>
fix perf regression from abby canonical form
2 parents 55c4dfe + 598fa63 commit 6045edf

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

compiler/rustc_type_ir/src/region_constraint.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<I: Interner> Or<I> {
240240
}
241241
impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> Or<I, S> {
242242
pub fn new_true() -> Self {
243-
Self(Box::new([And::new([])]))
243+
Self(Box::new([And::new_true()]))
244244
}
245245

246246
pub fn is_true(&self) -> bool {
@@ -323,6 +323,10 @@ impl<I: Interner> And<I> {
323323
}
324324
}
325325
impl<I: Interner, S: Clone + std::hash::Hash + std::fmt::Debug + Eq> And<I, S> {
326+
pub fn new_true() -> Self {
327+
Self(Box::new([]))
328+
}
329+
326330
pub fn new(i: impl IntoIterator<Item = LeafRegionConstraint<I, S>>) -> Self {
327331
let mut seen = IndexSet::new();
328332
And(i
@@ -406,7 +410,7 @@ impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConst
406410
}));
407411

408412
Self {
409-
and_constraint: if or_constraint.is_false() { And::new([]) } else { and_constraint },
413+
and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
410414
or_constraint,
411415
}
412416
}
@@ -422,7 +426,7 @@ impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConst
422426
let or_constraint = Or::build_and(a.or_constraint, b.or_constraint);
423427

424428
Self {
425-
and_constraint: if or_constraint.is_false() { And::new([]) } else { and_constraint },
429+
and_constraint: if or_constraint.is_false() { And::new_true() } else { and_constraint },
426430
or_constraint,
427431
}
428432
}
@@ -432,15 +436,15 @@ impl<I: Interner, S: Clone + std::fmt::Debug + Eq + std::hash::Hash> RegionConst
432436
}
433437

434438
pub fn new_true() -> Self {
435-
Self { and_constraint: And::new([]), or_constraint: Or::new_true() }
439+
Self { and_constraint: And::new_true(), or_constraint: Or::new_true() }
436440
}
437441

438442
pub fn is_true(&self) -> bool {
439443
self.and_constraint.0.is_empty() && self.or_constraint.is_true()
440444
}
441445

442446
pub fn new_false() -> Self {
443-
Self { and_constraint: And::new([]), or_constraint: Or::new_false() }
447+
Self { and_constraint: And::new_true(), or_constraint: Or::new_false() }
444448
}
445449

446450
pub fn is_false(&self) -> bool {

0 commit comments

Comments
 (0)