Skip to content
Permalink
Browse files

Make some initializations as Lists rather than Arrays

Because they are immutable in further usage, so this saves on creating
containers and de-containerizing when accessing.
  • Loading branch information...
lizmat committed Nov 11, 2018
1 parent bf3575c commit 18ded174e5947f6212305496614dd7a9c3e45bcf
@@ -285,7 +285,7 @@ class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationR
}
}

my @result = $out.lines.unique;
my @result is List = $out.lines.unique;
if $status { # something wrong
self.store.unlock;
$RMD("Precompiling $path failed: $status") if $RMD;
@@ -145,7 +145,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
self!bin-dir;
if ($version < 1) {
for $short-dir.dir -> $file {
my @ids = $file.lines.unique;
my @ids is List = $file.lines.unique;
$file.unlink;
$file.mkdir;
for @ids -> $id {
@@ -379,7 +379,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {

# Scripts using this interface could only have been installed long after the introduction of
# repo version 1, so we don't have to care about very old repos in this method.
my @dists = $lookup.dir.map({
my @dists is List = $lookup.dir.map({
my ($ver, $auth, $api, $resource-id) = $_.slurp.split("\n");
$resource-id ||= self!read-dist($_.basename)<files>{$file};
(id => $_.basename, ver => Version.new( $ver || 0 ), :$auth, :$api, :$resource-id).hash
@@ -398,7 +398,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
my $lookup = $prefix.add('short').add(nqp::sha1($name));
if $lookup.e {
my $repo-version = self!repository-version;
my @dists = $repo-version < 1
my @dists is List = $repo-version < 1
?? $lookup.lines.unique.map({
self!read-dist($_)
})
@@ -423,7 +423,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
my $repo-version = self!repository-version;
my $lookup = $.prefix.add('short').add(nqp::sha1($spec.short-name));
if $lookup.e {
my @dists = (
my @dists is List = (
$repo-version < 1
?? $lookup.lines.unique.map({
$_ => self!read-dist($_)
@@ -251,7 +251,7 @@ class CompUnit::RepositoryRegistry {
}

method file-for-spec(Str $spec) {
my @parts = $spec.split('#', 2);
my @parts is List = $spec.split('#', 2);
if @parts.elems == 2 {
my $repo = self.repository-for-name(@parts[0]);
return $repo.source-file(@parts[1]) if $repo.can('source-file');
@@ -264,7 +264,8 @@ class CompUnit::RepositoryRegistry {
shift @*ARGS if $auth;
shift @*ARGS if $ver;
$name //= $dist-name;
my @installations = $*REPO.repo-chain.grep(CompUnit::Repository::Installation);
my @installations is List =
$*REPO.repo-chain.grep(CompUnit::Repository::Installation);
my @binaries = @installations.map({ .script("bin/$script", :$name, :$auth, :$ver) }).grep(*.defined);
unless +@binaries {
@binaries = flat @installations.map: { .script("bin/$script", :$name) };

0 comments on commit 18ded17

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