Skip to content

Instantly share code, notes, and snippets.

@niner
Created February 24, 2020 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niner/3b8716dfc739abe669e39d70028b9e6f to your computer and use it in GitHub Desktop.
Save niner/3b8716dfc739abe669e39d70028b9e6f to your computer and use it in GitHub Desktop.
diff --git a/src/core.c/CompUnit/PrecompilationRepository.pm6 b/src/core.c/CompUnit/PrecompilationRepository.pm6
index 6680da21b..329253926 100644
--- a/src/core.c/CompUnit/PrecompilationRepository.pm6
+++ b/src/core.c/CompUnit/PrecompilationRepository.pm6
@@ -20,6 +20,7 @@ class CompUnit { ... }
class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationRepository {
has CompUnit::PrecompilationStore $.store;
my %loaded;
+ my %resolved;
my $loaded-lock = Lock.new;
my $first-repo-id;
@@ -124,11 +125,19 @@ class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationR
$RMD("dependency: $dependency") if $RMD;
if $resolve {
- my $comp-unit = $repo.resolve($dependency.spec);
- $RMD("Old id: $dependency.id(), new id: {$comp-unit.repo-id}") if $RMD;
- return False unless $comp-unit and $comp-unit.repo-id eq $dependency.id;
+ $loaded-lock.protect: {
+ %resolved{$dependency.serialize} //= do {
+ my $comp-unit = $repo.resolve($dependency.spec);
+ $RMD("Old id: $dependency.id(), new id: {$comp-unit.repo-id}") if $RMD;
+ return False unless $comp-unit and $comp-unit.repo-id eq $dependency.id;
+ True
+ };
+ }
}
+ $loaded-lock.protect: {
+ next if %loaded{$dependency.id}:exists;
+ }
my $dependency-precomp = @precomp-stores
.map({ $_.load-unit($compiler-id, $dependency.id) })
.first(*.defined)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment