From 4dd67830cb38c4dee5a30e6fd0730ebcdbca98ed Mon Sep 17 00:00:00 2001 From: Shawn Laffan Date: Sat, 24 Feb 2018 19:16:28 +1100 Subject: [PATCH] Use unfilled groups directly rather than rebuilding it each time 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 --- lib/Biodiverse/Randomise.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Biodiverse/Randomise.pm b/lib/Biodiverse/Randomise.pm index 7ef406ae7..2e26161ea 100644 --- a/lib/Biodiverse/Randomise.pm +++ b/lib/Biodiverse/Randomise.pm @@ -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) { @@ -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;