refactor to remove second loop

This commit is contained in:
Oliver Gorwits
2017-09-12 08:12:12 +01:00
parent 64a9491115
commit 1fdb086183

View File

@@ -63,19 +63,12 @@ sub run {
my @phase_hooks = grep { m/^nd2_${action}_/ }
@{ (setting('_nd2worker_hooks') || []) };
foreach my $stage (qw/init first second/) {
my $hookname = "nd2_${action}_${stage}";
next unless scalar @{ $store->get_hooks_for($hookname) };
$self->run_workers($hookname);
last if $stage eq 'init' and $self->jobstat->not_ok;
}
foreach my $phase (@phase_hooks) {
foreach my $phase ("nd2_${action}", @phase_hooks) {
foreach my $stage (qw/init first second/) {
my $hookname = "${phase}_${stage}";
next unless scalar @{ $store->get_hooks_for($hookname) };
$self->run_workers($hookname);
last if $stage eq 'init' and $self->jobstat->not_ok;
return if $stage eq 'init' and $self->jobstat->not_ok;
}
}
}