By checking for a CODE slot in the glob, we can avoid a lot of calls to
->has_method, which is quite expensive.
This seems to provide a speedup of approximately 10% when compiling
Markdent::Simple::Document (and all the classes it loads in turn).
sub get_method_list {
my $self = shift;
- return grep { $self->has_method($_) } keys %{ $self->namespace };
+
+ my $namespace = $self->namespace;
+
+ return grep { *{ $namespace->{$_} }{CODE} && $self->has_method($_) }
+ keys %{$namespace};
}
1;