Skip to content

Commit

Permalink
Indices: generalise early return condition in _calc_phylo_abc_lists
Browse files Browse the repository at this point in the history
We have already calculated the count of labels
unique to set 2 so if that is zero then we can
return early.
  • Loading branch information
shawnlaffan committed Mar 4, 2024
1 parent 1666094 commit d30dfea
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/Biodiverse/Indices/Phylogenetic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,9 @@ sub _calc_phylo_abc_lists {
el_list => $args{element_list1},
);

if (!@{$args{element_list2}}) {
# $args{C} is the count of labels unique to set 2
# so if it is zero then we can short-circuit.
if ($args{C} == 0) {
my $res = {
PHYLO_A_LIST => {},
PHYLO_B_LIST => $nodes_in_path1,
Expand All @@ -2703,14 +2705,12 @@ sub _calc_phylo_abc_lists {
return wantarray ? %$res : $res;
}

my $nodes_in_path2 = @{$args{element_list2}}
? $self->get_path_lengths_to_root_node (
%args,
labels => $label_hash2,
tree_ref => $tree,
el_list => $args{element_list2},
)
: {};
my $nodes_in_path2 = $self->get_path_lengths_to_root_node (
%args,
labels => $label_hash2,
tree_ref => $tree,
el_list => $args{element_list2},
);

my %results;
# one day we can clean this all up
Expand Down

0 comments on commit d30dfea

Please sign in to comment.