Skip to content

Commit 8ec0e9d

Browse files
committed
GUI: cache on terminal names in label range convex hull union
This avoids issues with trees that have similarly named nodes with different terminals.
1 parent 2f1d7ed commit 8ec0e9d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Biodiverse/GUI/Tabs/Labels.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,15 +998,19 @@ sub highlight_label_range_convex_hull_union {
998998
999999
my $cache = $bd->get_cached_value_dor_set_default_href('LABEL_RANGE_CONVEX_HULL_VERTICES');
10001000
1001-
my $hull_union = $cache->{$node->get_name};
1001+
# Cache on list of terminal names to avoid issues with trees
1002+
# that have similarly named nodes with different terminals.
1003+
my $cache_key = $node->is_terminal_node ? $node->get_name : $node->get_terminal_element_names_sha256;
1004+
1005+
my $hull_union = $cache->{$cache_key};
10021006
if (!$hull_union) {
10031007
# could climb up the tree if this takes too long
10041008
foreach my $label (keys %$terminal_elements) {
10051009
next LABEL if !exists $label_hash->{$label};
10061010
my $hull = $bd->get_label_range_convex_hull(label => $label);
10071011
$hull_union = $hull_union ? $hull_union->Union ($hull) : $hull;
10081012
}
1009-
$cache->{$node->get_name} = $hull_union;
1013+
$cache->{$cache_key} = $hull_union;
10101014
}
10111015
10121016
# avoid plotting empties

0 commit comments

Comments
 (0)