From 455e755bb011fff6d1389701063956fbf16daaf1 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 15 Mar 2021 19:13:49 +0100 Subject: Use SmallVec for Substs Doesn't help as much as I hoped, but it helps a bit and I also did some refactorings that were necessary anyway. --- crates/hir_ty/src/traits/chalk/interner.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk/interner.rs') diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index 1dc3f497d..94e94a26d 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs @@ -5,6 +5,7 @@ use super::tls; use base_db::salsa::InternId; use chalk_ir::{GenericArg, Goal, GoalData}; use hir_def::TypeAliasId; +use smallvec::SmallVec; use std::{fmt, sync::Arc}; #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] @@ -33,7 +34,7 @@ impl chalk_ir::interner::Interner for Interner { type InternedGenericArg = chalk_ir::GenericArgData; type InternedGoal = Arc>; type InternedGoals = Vec>; - type InternedSubstitution = Vec>; + type InternedSubstitution = SmallVec<[GenericArg; 2]>; type InternedProgramClause = Arc>; type InternedProgramClauses = Arc<[chalk_ir::ProgramClause]>; type InternedQuantifiedWhereClauses = Vec>; @@ -265,13 +266,13 @@ impl chalk_ir::interner::Interner for Interner { fn intern_substitution( &self, data: impl IntoIterator, E>>, - ) -> Result>, E> { + ) -> Result { data.into_iter().collect() } fn substitution_data<'a>( &self, - substitution: &'a Vec>, + substitution: &'a Self::InternedSubstitution, ) -> &'a [GenericArg] { substitution } -- cgit v1.2.3