Skip to content

Commit

Permalink
perf: Shrink Type's size to 48 bytes (from 64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Aug 31, 2019
1 parent 48a5313 commit 178180f
Show file tree
Hide file tree
Showing 16 changed files with 381 additions and 290 deletions.
13 changes: 9 additions & 4 deletions base/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,18 +815,23 @@ pub fn walk_ast_type<'a, V: ?Sized + $trait_name<'a>>(
Type::Effect(ref $($mut)* ast_type) => v.visit_ast_type(&$($mut)* ast_type._typ.typ),
Type::EmptyRow => (),
Type::ExtendRow {
ref $($mut)* types,
ref $($mut)* fields,
ref $($mut)* rest,
} => {
for field in fields {
v.visit_ast_type(&$($mut)* field.typ._typ.typ);
}
v.visit_ast_type(&$($mut)* rest._typ.typ);
}
Type::ExtendTypeRow {
ref $($mut)* types,
ref $($mut)* rest,
} => {
for field in types {
if let Some(alias) = field.typ.$try_get_alias() {
v.visit_ast_type(&$($mut)* alias.$unresolved_type()._typ.typ);
}
}
for field in fields {
v.visit_ast_type(&$($mut)* field.typ._typ.typ);
}
v.visit_ast_type(&$($mut)* rest._typ.typ);
}
Type::Alias(ref $($mut)* alias) => {
Expand Down
1 change: 1 addition & 0 deletions base/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl<T> AliasRemover<T> {
| Type::Effect(..)
| Type::EmptyRow
| Type::ExtendRow { .. }
| Type::ExtendTypeRow { .. }
if args.is_empty() =>
{
return Ok(typ)
Expand Down
5 changes: 4 additions & 1 deletion base/src/types/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ where
}
}
Type::Skolem(_) => *flags |= Flags::HAS_SKOLEMS,
Type::ExtendRow { fields, rest, .. } => {
Type::ExtendRow { fields, rest } => {
fields.add_flags(flags);
rest.add_flags(flags);
}
Type::ExtendTypeRow { rest, .. } => {
rest.add_flags(flags);
}
Type::Variable(_) => *flags |= Flags::HAS_VARIABLES,
Type::Generic(_) => *flags |= Flags::HAS_GENERICS,
Type::Ident(_) => *flags |= Flags::HAS_IDENTS,
Expand Down
Loading

0 comments on commit 178180f

Please sign in to comment.