Bläddra i källkod

Work on #246: get rid of some if...grep in favor of any()

Still need to put in a critic rule!
George Baugh 2 år sedan
förälder
incheckning
65b7525ccb
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 1 1
      lib/Trog/DataModule.pm
  2. 1 1
      lib/Trog/Routes/HTML.pm

+ 1 - 1
lib/Trog/DataModule.pm

@@ -102,7 +102,7 @@ sub _fixup ( $self, @filtered ) {
         }
 
         #XXX Add dynamic routing data for posts which don't have them (/posts/$id) and (/users/$user)
-        my $is_user_page = grep { $_ eq 'about' } @{ $subj->{tags} };
+        my $is_user_page = List::Util::any { $_ eq 'about' } @{ $subj->{tags} };
         if ( !exists $subj->{local_href} ) {
             $subj->{local_href} = "/posts/$subj->{id}";
             $subj->{local_href} = "/users/$subj->{user}" if $is_user_page;

+ 1 - 1
lib/Trog/Routes/HTML.pm

@@ -908,7 +908,7 @@ sub posts ( $query, $direct = 0 ) {
     }
 
     #OK, so if we have a user as the ID we found, go grab the rest of their posts
-    if ( $query->{id} && @posts && grep { $_ eq 'about' } @{ $posts[0]->{tags} } ) {
+    if ( $query->{id} && @posts && List::Util::any { $_ eq 'about' } @{ $posts[0]->{tags} } ) {
         my $user = shift(@posts);
         my $id   = delete $query->{id};
         $query->{author} = $user->{user};