From b321c48fd790790a0852681a96f500e25d14c41d Mon Sep 17 00:00:00 2001 From: shawnlaffan Date: Sun, 25 Feb 2024 16:58:39 +1100 Subject: [PATCH] Indices: optimise _calc_phylo_abc_lists If we have no second neighbour set then there is no need to run all the hash processing. --- lib/Biodiverse/Indices/Phylogenetic.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Biodiverse/Indices/Phylogenetic.pm b/lib/Biodiverse/Indices/Phylogenetic.pm index 22d33680f..2a5551e35 100644 --- a/lib/Biodiverse/Indices/Phylogenetic.pm +++ b/lib/Biodiverse/Indices/Phylogenetic.pm @@ -2679,6 +2679,15 @@ sub _calc_phylo_abc_lists { el_list => $args{element_list1}, ); + if (!@{$args{element_list2}}) { + my $res = { + PHYLO_A_LIST => {}, + PHYLO_B_LIST => $nodes_in_path1, + PHYLO_C_LIST => {}, + }; + return wantarray ? %$res : $res; + } + my $nodes_in_path2 = @{$args{element_list2}} ? $self->get_path_lengths_to_root_node ( %args,