Skip to content

Commit

Permalink
perf: Avoid recursing in gather_foralls
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Jan 27, 2019
1 parent 1713a44 commit 6a38f43
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion check/src/typecheck/generalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::base::{
fnv::{FnvMap, FnvSet},
pos::{BytePos, Span},
symbol::Symbol,
types::{self, AppVec, ArcType, BuiltinType, Generic, Type, TypeInterner},
types::{self, AppVec, ArcType, BuiltinType, Flags, Generic, Type, TypeExt, TypeInterner},
};

use crate::{substitution::Substitution, typ::RcType, typecheck::Typecheck};
Expand Down Expand Up @@ -252,6 +252,12 @@ struct TypeVariableGenerator {
impl TypeVariableGenerator {
fn new(subs: &Substitution<RcType>, typ: &RcType) -> TypeVariableGenerator {
fn gather_foralls(map: &mut FnvSet<Symbol>, subs: &Substitution<RcType>, typ: &RcType) {
if !typ
.flags()
.intersects(Flags::HAS_VARIABLES | Flags::HAS_FORALL)
{
return;
}
let typ = subs.real(typ);
if let Type::Forall(ref params, _) = **typ {
map.extend(params.iter().map(|param| param.id.clone()));
Expand Down

0 comments on commit 6a38f43

Please sign in to comment.