aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-15 18:13:49 +0000
committerFlorian Diebold <[email protected]>2021-03-15 18:48:03 +0000
commit455e755bb011fff6d1389701063956fbf16daaf1 (patch)
tree400efb6e39a557454edd99184c005b413ae25af3 /crates/hir_ty/src/traits/chalk
parent47b74cadf9774f624ff13f8c7929c66be8247fc8 (diff)
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.
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs7
1 files changed, 4 insertions, 3 deletions
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;
5use base_db::salsa::InternId; 5use base_db::salsa::InternId;
6use chalk_ir::{GenericArg, Goal, GoalData}; 6use chalk_ir::{GenericArg, Goal, GoalData};
7use hir_def::TypeAliasId; 7use hir_def::TypeAliasId;
8use smallvec::SmallVec;
8use std::{fmt, sync::Arc}; 9use std::{fmt, sync::Arc};
9 10
10#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 11#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
@@ -33,7 +34,7 @@ impl chalk_ir::interner::Interner for Interner {
33 type InternedGenericArg = chalk_ir::GenericArgData<Self>; 34 type InternedGenericArg = chalk_ir::GenericArgData<Self>;
34 type InternedGoal = Arc<GoalData<Self>>; 35 type InternedGoal = Arc<GoalData<Self>>;
35 type InternedGoals = Vec<Goal<Self>>; 36 type InternedGoals = Vec<Goal<Self>>;
36 type InternedSubstitution = Vec<GenericArg<Self>>; 37 type InternedSubstitution = SmallVec<[GenericArg<Self>; 2]>;
37 type InternedProgramClause = Arc<chalk_ir::ProgramClauseData<Self>>; 38 type InternedProgramClause = Arc<chalk_ir::ProgramClauseData<Self>>;
38 type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>; 39 type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>;
39 type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>; 40 type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
@@ -265,13 +266,13 @@ impl chalk_ir::interner::Interner for Interner {
265 fn intern_substitution<E>( 266 fn intern_substitution<E>(
266 &self, 267 &self,
267 data: impl IntoIterator<Item = Result<GenericArg<Self>, E>>, 268 data: impl IntoIterator<Item = Result<GenericArg<Self>, E>>,
268 ) -> Result<Vec<GenericArg<Self>>, E> { 269 ) -> Result<Self::InternedSubstitution, E> {
269 data.into_iter().collect() 270 data.into_iter().collect()
270 } 271 }
271 272
272 fn substitution_data<'a>( 273 fn substitution_data<'a>(
273 &self, 274 &self,
274 substitution: &'a Vec<GenericArg<Self>>, 275 substitution: &'a Self::InternedSubstitution,
275 ) -> &'a [GenericArg<Self>] { 276 ) -> &'a [GenericArg<Self>] {
276 substitution 277 substitution
277 } 278 }