Skip to content
Browse files

Make Mu.isa(Str) about 2x as fast

Mostly by avoiding a copy of Foo.^mro.  As a bonus, it's now also
idiomatic Perl 6.  Also add --> Bool:D signature.
  • Loading branch information...
lizmat committed Sep 30, 2018
1 parent bda8c1e commit 4e8740c807a91c56e62bc59e0bf69046d6096f07
Showing with 3 additions and 10 deletions.
  1. +3 −10 src/core/Mu.pm6
@@ -708,18 +708,11 @@ Perhaps it can be found at$name"

proto method isa(|) {*}
multi method isa(Mu \SELF: Mu $type) {
multi method isa(Mu \SELF: Mu $type --> Bool:D) {
multi method isa(Mu \SELF: Str:D $name) {
my @mro = SELF.^mro;
my int $mro_count = @mro.elems;
my int $i = -1;

return True
if @mro[$i].^name eq $name
while nqp::islt_i(++$i,$mro_count);

multi method isa(Mu \SELF: Str:D $name --> Bool:D) {
return True if .^name eq $name for SELF.^mro;

0 comments on commit 4e8740c

Please sign in to comment.
You can’t perform that action at this time.