Skip to content

Commit

Permalink
Use unfilled groups directly rather than rebuilding it each time
Browse files Browse the repository at this point in the history
We were setting the target groups to the full possible set and
then trimming out the filled groups.  It makes more sense to
use the unfilled groups, since we are tracking them anyway.

updates #685
  • Loading branch information
shawnlaffan committed Feb 24, 2018
1 parent 2be7f51 commit 4dd6783
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Biodiverse/Randomise.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ END_PROGRESS_TEXT
# we don't need the values, and slice assignment to undef is
# faster than straight copy (close to twice as fast)
my %target_groups_hash;
@target_groups_hash{keys %all_target_groups} = ();
@target_groups_hash{keys %unfilled_groups} = ();

# don't consider groups that are full or that already have this label
if (scalar keys %$new_bd_has_label) {
Expand All @@ -1707,10 +1707,10 @@ END_PROGRESS_TEXT
my $check = scalar keys %all_target_groups;
my $check2 = $check;
if (scalar keys %filled_groups) {
delete @target_groups_hash{keys %filled_groups};
# delete @target_groups_hash{keys %filled_groups};
$check = scalar keys %target_groups_hash;
# grep is not faster than the slice delete in this case
#my @checker_temp_test = grep {!exists $filled_groups{$_}} keys %target_groups_hash;
# # grep is not faster than the slice delete in this case
# #my @checker_temp_test = grep {!exists $filled_groups{$_}} keys %target_groups_hash;
}
@target_groups = sort keys %target_groups_hash;

Expand Down

0 comments on commit 4dd6783

Please sign in to comment.