Skip to content
Permalink
Browse files

Minor optimization for cache lookup

  • Loading branch information...
ugexe committed Sep 28, 2018
1 parent 339ea85 commit 3999d753c3d798831728454443a00a102b519266
Showing with 4 additions and 5 deletions.
  1. +2 −3 src/core/CompUnit/Repository/FileSystem.pm6
  2. +2 −2 src/core/CompUnit/Repository/Installation.pm6
@@ -9,7 +9,7 @@ class CompUnit::Repository::FileSystem does CompUnit::Repository::Locally does C
my @extensions = <pm6 pm>;

method !matching-dist(CompUnit::DependencySpecification $spec) {
return %!seen{~$spec} if %!seen{~$spec}:exists;
return $_ with %!seen{~$spec};

with self.candidates($spec).head {
return %!seen{~$spec} //= $_;
@@ -66,7 +66,7 @@ class CompUnit::Repository::FileSystem does CompUnit::Repository::Locally does C

--> CompUnit:D)
{
return %!loaded{~$spec} if %!loaded{~$spec}:exists;
return $_ with %!loaded{~$spec};

with self!matching-dist($spec) {
my $name = $spec.short-name;
@@ -152,7 +152,6 @@ class CompUnit::Repository::FileSystem does CompUnit::Repository::Locally does C
return Empty unless $spec.from eq 'Perl6';

my $distribution := self!distribution;

return Empty unless ($distribution.meta<provides> && $distribution.meta<provides>{$spec.short-name})
or ($distribution.meta<files> && $distribution.meta<files>{$spec.short-name});

@@ -458,7 +458,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {

# An equivalent of self.candidates($spec).head that caches the best match
method !matching-dist(CompUnit::DependencySpecification $spec) {
return %!seen{~$spec} if %!seen{~$spec}:exists;
return $_ with %!seen{~$spec};

with self.candidates($spec).head {
$!lock.protect: { return %!seen{~$spec} //= $_ }
@@ -563,7 +563,7 @@ sub MAIN(:$name, :$auth, :$ver, *@, *%) {
unless $source-file-name;
my $loader = $.prefix.add('sources').add($source-file-name);
my $id = $loader.basename;
return %!loaded{$id} if %!loaded{$id}:exists;
return $_ with %!loaded{$id};

my $*RESOURCES = Distribution::Resources.new(:repo(self), :dist-id(.dist-id));
my $repo-prefix = self!repo-prefix;

0 comments on commit 3999d75

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