]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
simplifiy
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 27 Mar 2009 19:23:36 +0000 (15:23 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 27 Mar 2009 19:23:36 +0000 (15:23 -0400)
IkiWiki/Plugin/rename.pm

index de11e4cc91cef699544510779c368907afebbe75..09250af8198eae4dfcb9602c1e7b4a1008ca2f5f 100644 (file)
@@ -486,34 +486,31 @@ sub rename_hook (@) {
        my $q=$params{cgi};
        my $session=$params{session};
 
+       return () unless @torename;
+
        my @nextset;
-       if (@torename) {
-               foreach my $torename (@torename) {
-                       unless (exists $done{$torename->{src}} && $done{$torename->{src}}) {
-                               IkiWiki::run_hooks(rename => sub {
-                                       push @nextset, shift->(
-                                               torename => $torename,
-                                               cgi => $q,
-                                               session => $session,
-                                       );
-                               });
-                               $done{$torename->{src}}=1;
-                       }
+       foreach my $torename (@torename) {
+               unless (exists $done{$torename->{src}} && $done{$torename->{src}}) {
+                       IkiWiki::run_hooks(rename => sub {
+                               push @nextset, shift->(
+                                       torename => $torename,
+                                       cgi => $q,
+                                       session => $session,
+                               );
+                       });
+                       $done{$torename->{src}}=1;
                }
-               push @torename, rename_hook(
-                       torename => \@nextset,
-                       done => \%done,
-                       cgi => $q,
-                       session => $session,
-               );
-
-               # remove duplicates from @torename
-               my %seen;
-               return grep { ! $seen{$_->{src}}++ } @torename;
-       }
-       else {
-               return ();
        }
+       push @torename, rename_hook(
+               torename => \@nextset,
+               done => \%done,
+               cgi => $q,
+               session => $session,
+       );
+
+       # dedup
+       my %seen;
+       return grep { ! $seen{$_->{src}}++ } @torename;
 }
 
 sub do_rename ($$$) {