Skip to content

Commit

Permalink
Micro-optimize calls to HOW
Browse files Browse the repository at this point in the history
Pre-cache `$_.HOW` where it's used more than once.

Also fix a typo in ParametricRoleHOW.
  • Loading branch information
vrurg committed Jun 17, 2021
1 parent 4b99656 commit 6e1cfe4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Perl6/Metamodel/CurriedRoleHOW.nqp
Expand Up @@ -133,10 +133,11 @@ class Perl6::Metamodel::CurriedRoleHOW
# for $!curried_role.HOW.role_typecheck_list($obj) {
# nqp::push(@rtl, $_);
# }
for self.roles_to_compose($obj) {
if $_.HOW.archetypes.composable() || $_.HOW.archetypes.composalizable() {
nqp::push(@rtl, $_);
for $_.HOW.role_typecheck_list($_) {
for self.roles_to_compose($obj) -> $role {
my $how := $role.HOW;
if $how.archetypes.composable() || $how.archetypes.composalizable() {
nqp::push(@rtl, $role);
for $how.role_typecheck_list($role) {
nqp::push(@rtl, $_);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Metamodel/ParametricRoleHOW.nqp
Expand Up @@ -237,7 +237,7 @@ class Perl6::Metamodel::ParametricRoleHOW
# the case they're generic (role Foo[::T] is T { })
for self.parents($obj, :local(1)) {
my $p := $_;
if $_.HOW.archetypes.generic {
if $p.HOW.archetypes.generic {
$p := $p.HOW.instantiate_generic($p, $type_env);
}
$conc.HOW.add_parent($conc, $p, :hides(self.hides_parent($obj, $_)));
Expand Down

0 comments on commit 6e1cfe4

Please sign in to comment.