From d26ccbbcd5d2eb3f419b750c4ad93c43aed134a2 Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Thu, 28 Mar 2013 07:08:08 -0500 Subject: in get_build_queue(), keep last instance of repeated thing instead of first, so final queue is ordered correctly. --- SBO-Lib/lib/SBO/Lib.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'SBO-Lib/lib/SBO/Lib.pm') diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 770e300..13f5057 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -957,12 +957,14 @@ sub get_build_queue { ); add_to_queue(\%args); } - # Remove duplicate entries (leaving first occurrence) + # Remove duplicate entries (leaving last occurrence) + @$temp_queue = reverse @$temp_queue; my (%seen, @build_queue); FIRST: for my $sb (@$temp_queue) { next FIRST if $seen{$sb}++; push @build_queue, $sb; } + @build_queue = reverse @build_queue; return \@build_queue; } -- cgit v1.2.3 From 7c90f21cbea304210d113fad4d918cde72cb0eae Mon Sep 17 00:00:00 2001 From: J Pipkin Date: Sat, 30 Mar 2013 12:20:26 -0500 Subject: modification to last change for conciseness, and get rid of useless add_to_queue() prototype --- SBO-Lib/lib/SBO/Lib.pm | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'SBO-Lib/lib/SBO/Lib.pm') diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 13f5057..b34d6f5 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -924,10 +924,8 @@ sub get_requires($) { return $$info[0] ne '' ? $info : undef; } -# avoid being called to early to check prototype when add_to_queue calls itself -sub add_to_queue($); # used by get_build_queue. -sub add_to_queue($) { +sub add_to_queue { my $args = shift; my $sbo = \${$args}{NAME}; return unless $$sbo; @@ -958,12 +956,9 @@ sub get_build_queue { add_to_queue(\%args); } # Remove duplicate entries (leaving last occurrence) - @$temp_queue = reverse @$temp_queue; - my (%seen, @build_queue); - FIRST: for my $sb (@$temp_queue) { - next FIRST if $seen{$sb}++; - push @build_queue, $sb; - } + my @build_queue = reverse @$temp_queue; + my %seen; + @build_queue = grep {!$seen{$_}++} @build_queue; @build_queue = reverse @build_queue; return \@build_queue; } -- cgit v1.2.3