Skip to content

Commit

Permalink
GUI: use ternaries in Dendrogram::recolour_cluster_elements
Browse files Browse the repository at this point in the history
Might make a small speed difference.
  • Loading branch information
shawnlaffan committed Jan 9, 2024
1 parent e658412 commit 81a3341
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions lib/Biodiverse/GUI/Dendrogram.pm
Original file line number Diff line number Diff line change
Expand Up @@ -902,18 +902,16 @@ sub recolour_cluster_elements {
$colour_callback = sub {
my $elt = shift;
my $cluster_node = $self->{element_to_cluster}{$elt};

if ($cluster_node) {
my $colour_ref = $self->{node_palette_colours}{$cluster_node->get_name};
return $colour_ref || COLOUR_PALETTE_OVERFLOW;
}
else {
return exists $terminal_elements->{$elt}
? COLOUR_OUTSIDE_SELECTION
: $self->get_colour_not_in_tree;
}

die "how did I get here?\n";

my $colour_ref
= $cluster_node ? (
$self->{node_palette_colours}{$cluster_node->get_name}
|| COLOUR_PALETTE_OVERFLOW
)
: exists $terminal_elements->{$elt} ? COLOUR_OUTSIDE_SELECTION
: $self->get_colour_not_in_tree;

return $colour_ref;
};
}
elsif ($self->in_multiselect_mode) {
Expand Down Expand Up @@ -952,7 +950,6 @@ sub recolour_cluster_elements {
my $cluster_node = $self->{element_to_cluster}{$elt};

if ($cluster_node) {
no autovivification;

my $list_ref = $cluster_node->get_list_ref (list => $list_name)
// return $colour_for_undef;
Expand All @@ -962,13 +959,11 @@ sub recolour_cluster_elements {

return $legend->$colour_method ($val, @minmax_args);
}
else {
return exists $terminal_elements->{$elt}
? COLOUR_OUTSIDE_SELECTION
: $self->get_colour_not_in_tree;
}

die "how did I get here?\n";
return exists $terminal_elements->{$elt}
? COLOUR_OUTSIDE_SELECTION
: $self->get_colour_not_in_tree;

};
}

Expand Down

0 comments on commit 81a3341

Please sign in to comment.