summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-12-17 16:33:25 +0100
committerFlorian Pritz <bluewind@xinu.at>2018-12-17 16:33:25 +0100
commitf2b5d9bacf8e109fe27cea8f68232d41fd3b3ea5 (patch)
tree6f56fe0013bc8cb43d53a162f030adbf797af850
parent20e07437f413e338f2b54447133e1533f5262c13 (diff)
downloadApp-ArchLinux-PackagerTools-f2b5d9bacf8e109fe27cea8f68232d41fd3b3ea5.tar.gz
App-ArchLinux-PackagerTools-f2b5d9bacf8e109fe27cea8f68232d41fd3b3ea5.tar.xz
Make context parameter explicit
This prevents a loop in $deps->{..}->{context} which is 1) unnecessary and 2) potentially breaks memory recovery when things get deleted. Not the case right now, but whatever. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--lib/App/ArchLinux/PackagerTools.pm13
-rw-r--r--lib/App/ArchLinux/PackagerTools/CPAN.pm12
-rw-r--r--lib/App/ArchLinux/PackagerTools/CPAN/PackagesDetailsFetcher.pm8
-rw-r--r--lib/App/ArchLinux/PackagerTools/Cache.pm12
-rw-r--r--lib/App/ArchLinux/PackagerTools/Config.pm10
-rw-r--r--lib/App/ArchLinux/PackagerTools/Pacman.pm8
6 files changed, 31 insertions, 32 deletions
diff --git a/lib/App/ArchLinux/PackagerTools.pm b/lib/App/ArchLinux/PackagerTools.pm
index 0fbd224..8fc22f9 100644
--- a/lib/App/ArchLinux/PackagerTools.pm
+++ b/lib/App/ArchLinux/PackagerTools.pm
@@ -37,15 +37,14 @@ App::ArchLinux::PackagerTools is ...
Returns a new instance.
=cut
-method new($class: $deps = {}) {
- $deps->{context} //= {};
- $deps->{config} //= App::ArchLinux::PackagerTools::Config->new({$deps->%{context}});
- $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new({$deps->%{context}});
- $deps->{pacman} //= App::ArchLinux::PackagerTools::Pacman->new({$deps->%{context}});
- return $class->new_no_defaults($deps);
+method new($class: $context = {}, $deps = {}) {
+ $deps->{config} //= App::ArchLinux::PackagerTools::Config->new($context);
+ $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new($context);
+ $deps->{pacman} //= App::ArchLinux::PackagerTools::Pacman->new($context);
+ return $class->new_no_defaults($context, $deps);
}
-method new_no_defaults($class: $deps = {}) {
+method new_no_defaults($class: $context, $deps = {}) {
my $self = {};
bless $self, $class;
$self->{deps} = $deps;
diff --git a/lib/App/ArchLinux/PackagerTools/CPAN.pm b/lib/App/ArchLinux/PackagerTools/CPAN.pm
index de2a397..c48469a 100644
--- a/lib/App/ArchLinux/PackagerTools/CPAN.pm
+++ b/lib/App/ArchLinux/PackagerTools/CPAN.pm
@@ -37,20 +37,20 @@ Returns a new instance.
=cut
-method new($class: $deps = {}) {
- $deps->{packages_details_fetcher} //= App::ArchLinux::PackagerTools::CPAN::PackagesDetailsFetcher->new({$deps->%{context}});
- return $class->new_no_defaults($deps);
+method new($class: $context, $deps = {}) {
+ $deps->{packages_details_fetcher} //= App::ArchLinux::PackagerTools::CPAN::PackagesDetailsFetcher->new($context);
+ return $class->new_no_defaults($context, $deps);
}
-method new_no_defaults($class: $deps = {}) {
- return $deps->{context}->{$class} if defined $deps->{context}->{$class};
+method new_no_defaults($class: $context, $deps = {}) {
+ return $context->{$class} if defined $context->{$class};
my $self = {};
bless $self, $class;
$self->{deps} = $deps;
$self->{dist_lc_map} = {};
$self->{dists} = {};
- $deps->{context}->{$class} = $self;
+ $context->{$class} = $self;
$log->debug("Initialized new CPAN object");
return $self;
}
diff --git a/lib/App/ArchLinux/PackagerTools/CPAN/PackagesDetailsFetcher.pm b/lib/App/ArchLinux/PackagerTools/CPAN/PackagesDetailsFetcher.pm
index 734669c..88122da 100644
--- a/lib/App/ArchLinux/PackagerTools/CPAN/PackagesDetailsFetcher.pm
+++ b/lib/App/ArchLinux/PackagerTools/CPAN/PackagesDetailsFetcher.pm
@@ -30,12 +30,12 @@ Returns a new instance.
=cut
-method new($class: $deps = {}) {
- $deps->{cache} //= App::ArchLinux::PackagerTools::Cache->new({$deps->%{context}});
- return $class->new_no_defaults($deps);
+method new($class: $context, $deps = {}) {
+ $deps->{cache} //= App::ArchLinux::PackagerTools::Cache->new($context);
+ return $class->new_no_defaults($context, $deps);
}
-method new_no_defaults($class: $deps = {}) {
+method new_no_defaults($class: $context, $deps = {}) {
my $self = {};
bless $self, $class;
$self->{deps} = $deps;
diff --git a/lib/App/ArchLinux/PackagerTools/Cache.pm b/lib/App/ArchLinux/PackagerTools/Cache.pm
index b8415ad..6d5bec3 100644
--- a/lib/App/ArchLinux/PackagerTools/Cache.pm
+++ b/lib/App/ArchLinux/PackagerTools/Cache.pm
@@ -31,13 +31,13 @@ Returns a new instance.
=cut
-method new($class: $deps = {}) {
- $deps->{config} //= App::ArchLinux::PackagerTools::Config->new({$deps->%{context}});
- return $class->new_no_defaults($deps);
+method new($class: $context, $deps = {}) {
+ $deps->{config} //= App::ArchLinux::PackagerTools::Config->new($context);
+ return $class->new_no_defaults($context, $deps);
}
-method new_no_defaults($class: $deps = {}) {
- return $deps->{context}->{$class} if defined $deps->{context}->{$class};
+method new_no_defaults($class: $context, $deps = {}) {
+ return $context->{$class} if defined $context->{$class};
my $self = {};
bless $self, $class;
@@ -50,7 +50,7 @@ method new_no_defaults($class: $deps = {}) {
root_dir => $config->{cache}->{root_dir},
cache_size => $config->{cache}->{cache_size},
);
- $deps->{context}->{$class} = $self;
+ $context->{$class} = $self;
return $self;
}
diff --git a/lib/App/ArchLinux/PackagerTools/Config.pm b/lib/App/ArchLinux/PackagerTools/Config.pm
index 470a1ae..a58e82d 100644
--- a/lib/App/ArchLinux/PackagerTools/Config.pm
+++ b/lib/App/ArchLinux/PackagerTools/Config.pm
@@ -32,17 +32,17 @@ Returns a new instance.
=cut
-method new($class: $deps = {}) {
- return $class->new_no_defaults($deps);
+method new($class: $context, $deps = {}) {
+ return $class->new_no_defaults($context, $deps);
}
-method new_no_defaults($class: $deps = {}) {
- return $deps->{context}->{$class} if defined $deps->{context}->{$class};
+method new_no_defaults($class: $context, $deps = {}) {
+ return $context->{$class} if defined $context->{$class};
my $self = {};
bless $self, $class;
$self->{deps} = $deps;
- $deps->{context}->{$class} = $self;
+ $context->{$class} = $self;
return $self;
}
diff --git a/lib/App/ArchLinux/PackagerTools/Pacman.pm b/lib/App/ArchLinux/PackagerTools/Pacman.pm
index f541721..3204ca1 100644
--- a/lib/App/ArchLinux/PackagerTools/Pacman.pm
+++ b/lib/App/ArchLinux/PackagerTools/Pacman.pm
@@ -35,17 +35,17 @@ Returns a new instance.
=cut
-method new($class: $deps = {}) {
- $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new({$deps->%{context}});
+method new($class: $context, $deps = {}) {
+ $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new($context);
$deps->{pkgname_cpan_name_map} //= {
# pkgname => cpan_name
'perl-critic' => 'Perl::Critic',
'perl-libintl-perl' => 'libintl-perl',
};
- return $class->new_no_defaults($deps);
+ return $class->new_no_defaults($context, $deps);
}
-method new_no_defaults($class: $deps = {}) {
+method new_no_defaults($class: $context, $deps = {}) {
my $self = {};
bless $self, $class;
$deps->{cpan_name_pkgname_map} = {reverse $deps->{pkgname_cpan_name_map}->%*};