From 70a219d9c272e21ee3ec06320c4230e620fa1ca4 Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <art1@andreas-romeyke.de> Date: Thu, 15 Jul 2021 10:49:11 +0200 Subject: [PATCH] - changed order in if-elsif-else to handle most frequent case first --- perl/exit_strategy.pl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/perl/exit_strategy.pl b/perl/exit_strategy.pl index cbbbd03..d584095 100644 --- a/perl/exit_strategy.pl +++ b/perl/exit_strategy.pl @@ -324,15 +324,10 @@ sub check_if_db_conform ($$) { my $repids = $xp->find($compiled_xpath_amdsecs); #/mets:mets/mets:amdSec my $repid; my @repnodes = $repids->get_nodelist; - if (scalar @repnodes == 0) { - say STDERR "No reppid found in file $filename, is IE purged?"; - my %tmp; - $tmp{"filename"}=$filename; - $tmp{"purged"}=1; - return \%tmp; - } elsif (scalar @repnodes == 1) { + my $found = scalar @repnodes; + if (1 == $found) { $repid = $repnodes[0]->findvalue($compiled_xpath_id); - } else { #multiple representations found + } elsif ($found > 1) { #multiple representations found # choose reppid with LZA, LZA_INTERN or LOCAL (for very old IEs) foreach my $node (@repnodes) { my $id = $node->findvalue($compiled_xpath_id); @@ -348,6 +343,12 @@ sub check_if_db_conform ($$) { } #print XML::XPath::XMLParser::as_string($node), "\n\n"; } + } elsif (0 == $found) { + say STDERR "No reppid found in file $filename, is IE purged?"; + my %tmp; + $tmp{"filename"}=$filename; + $tmp{"purged"}=1; + return \%tmp; } if (!defined $repid) { say "No repid found in file $filename"; -- GitLab