]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
move dedup code into function, simplify
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 27 Mar 2009 19:21:21 +0000 (15:21 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 27 Mar 2009 19:21:21 +0000 (15:21 -0400)
IkiWiki/Plugin/rename.pm

index d3ca8bd3a4b585d67b6792207bc1a89f76ade3e0..de11e4cc91cef699544510779c368907afebbe75 100644 (file)
@@ -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;