Skip to content

Commit

Permalink
BaseStruct.pm: use array args sub in sort_by_axes
Browse files Browse the repository at this point in the history
Marginally faster.
  • Loading branch information
shawnlaffan committed Sep 23, 2023
1 parent e822270 commit 407e5fa
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/Biodiverse/BaseStruct.pm
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,12 @@ sub get_element_list {
}

sub sort_by_axes {
my $self = shift;
my $item_a = shift;
my $item_b = shift;
my ($self, $item_a, $item_b) = @_;

my $axes = $self->get_cell_sizes;
my $res = 0;
my $a_array = $self->get_element_name_as_array (element => $item_a);
my $b_array = $self->get_element_name_as_array (element => $item_b);
my $a_array = $self->get_element_name_as_array_aa($item_a);
my $b_array = $self->get_element_name_as_array_aa( $item_b);
foreach my $i (0 .. $#$axes) {
$res = $axes->[$i] < 0
? $a_array->[$i] cmp $b_array->[$i]
Expand Down

0 comments on commit 407e5fa

Please sign in to comment.