[tbb-commits] [rbm/master] Bug 40004: Improve cache in project_config
gk at torproject.org
gk at torproject.org
Wed Sep 16 19:24:14 UTC 2020
commit a32239ddb1f465115cb4a8bb9f4b853c149506f3
Author: Nicolas Vigier <boklm at torproject.org>
Date: Mon Sep 14 15:40:10 2020 +0200
Bug 40004: Improve cache in project_config
---
lib/RBM.pm | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/lib/RBM.pm b/lib/RBM.pm
index 6277de4..825502a 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -206,19 +206,16 @@ sub confkey_str {
sub project_config {
my ($project, $name, $options) = @_;
- CORE::state $cache;
+ CORE::state %config_cache;
my $res;
my $error_if_undef = $options->{error_if_undef};
- my $cache_save = $cache;
- if ($options) {
- $options = {%$options, error_if_undef => 0};
- my %ignore_options = map { $_ => 1 } qw(error_if_undef step);
- $cache = {} if grep { !$ignore_options{$_} } keys %$options;
- }
+ $options = {%$options, error_if_undef => 0} if $options;
+ my $cache_id = pp($config->{run})
+ . pp({ %{$config->{opt}}, $options ? %$options : () });
my $name_str = ref $name eq 'ARRAY' ? join '/', @$name : $name;
my $step = $config->{step};
- if (exists $cache->{$project}{$step}{$name_str}) {
- $res = $cache->{$project}{$step}{$name_str};
+ if (exists $config_cache{$project}{$step}{$name_str}{$cache_id}) {
+ $res = $config_cache{$project}{$step}{$name_str}{$cache_id};
goto FINISH;
}
$name = [ split '/', $name ] unless ref $name eq 'ARRAY';
@@ -233,10 +230,9 @@ sub project_config {
$res = process_template($project, $res,
confkey_str($name) eq 'output_dir' ? '.' : undef);
}
- $cache->{$project}{$step}{$name_str} = $res;
+ $config_cache{$project}{$step}{$name_str}{$cache_id} = $res;
$config->{opt} = $opt_save;
FINISH:
- $cache = $cache_save;
if (!defined($res) && $error_if_undef) {
my $msg = $error_if_undef eq '1' ?
"Option " . confkey_str($name) . " is undefined"
More information about the tbb-commits
mailing list