From f9fd71df88e73d54f889eab48c16563d2d41f77d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 27 Mar 2009 15:21:21 -0400 Subject: move dedup code into function, simplify --- IkiWiki/Plugin/rename.pm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index d3ca8bd3a..de11e4cc9 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -319,14 +319,6 @@ sub sessioncgi ($$) { session => $session, ); - # remove duplicates from @torename - my %seen=(); - my @uniq_torename; - foreach my $item (@torename) { - push(@uniq_torename, $item) unless $seen{$item->{src}}++; - } - @torename=@uniq_torename; - require IkiWiki::Render; IkiWiki::disable_commit_hook() if $config{rcs}; my %origpagesources=%pagesources; @@ -514,13 +506,16 @@ sub rename_hook (@) { cgi => $q, session => $session, ); - return @torename; + + # remove duplicates from @torename + my %seen; + return grep { ! $seen{$_->{src}}++ } @torename; } else { return (); } } - + sub do_rename ($$$) { my $rename=shift; my $q=shift; -- cgit v1.2.3