commit dab4ae35aeb84ae5273a30f1fbcdcb6b6530f8ad Author: Nicolas Vigier boklm@torproject.org Date: Thu Sep 10 13:11:28 2020 +0200
Bug 33289: Optimize the get_target function
We also change the behavior of the function: we stop looking after the first definition of a target. This means for example that if a target is defined as an array in rbm.conf, and also defined as a hash in the project's config, then the definition from rbm.conf will be ignored. --- lib/RBM.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/lib/RBM.pm b/lib/RBM.pm index b9ad1ad..c4d5a82 100644 --- a/lib/RBM.pm +++ b/lib/RBM.pm @@ -102,21 +102,17 @@ sub as_array {
sub get_target { my ($project, $options, $paths, $target) = @_; - my @res; foreach my $path (@$paths) { foreach my $step ([ 'steps', $config->{step} ], []) { my $z = config_p($config, $project, $options, @$path, @$step, 'targets', $target); next unless $z; - if (ref $z eq 'HASH') { - push @res, $target unless grep { $_ eq $target } @res; - next; - } + return [ $target ] if ref $z eq 'HASH'; my @z = ref $z eq 'ARRAY' ? (@{$z}) : ($z); - push @res, map { @{get_target($project, $options, $paths, $_)} } @z; + return [ map { @{get_target($project, $options, $paths, $_)} } @z ]; } } - return @res; + return []; }
sub get_targets {
tbb-commits@lists.torproject.org