From: Joey Hess Date: Fri, 27 Mar 2009 19:21:21 +0000 (-0400) Subject: move dedup code into function, simplify X-Git-Tag: 3.15~203 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f9fd71df88e73d54f889eab48c16563d2d41f77d;p=ikiwiki.git move dedup code into function, simplify --- 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;