Skip to content

Commit 317c4b9

Browse files
committed
Intern CanonicalVarKinds
Slight savings in performance and memory.
1 parent 90656f8 commit 317c4b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/hir_ty/src/traits/chalk/interner.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl_internable!(
5656
InternedTypeInner,
5757
InternedWrapper<chalk_ir::LifetimeData<Interner>>,
5858
InternedWrapper<chalk_ir::ConstData<Interner>>,
59+
InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
5960
);
6061

6162
impl chalk_ir::interner::Interner for Interner {
@@ -71,7 +72,7 @@ impl chalk_ir::interner::Interner for Interner {
7172
type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>;
7273
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
7374
type InternedVariableKinds = Interned<InternedVariableKindsInner>;
74-
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
75+
type InternedCanonicalVarKinds = Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
7576
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
7677
type InternedVariances = Arc<[chalk_ir::Variance]>;
7778
type DefId = InternId;
@@ -370,7 +371,7 @@ impl chalk_ir::interner::Interner for Interner {
370371
&self,
371372
data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
372373
) -> Result<Self::InternedCanonicalVarKinds, E> {
373-
data.into_iter().collect()
374+
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
374375
}
375376

376377
fn canonical_var_kinds_data<'a>(

0 commit comments

Comments
 (0)