vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[ljcom] r7181: LJSUP-4179: remove "my $x if cond()" con...

Committer: vad
LJSUP-4179: remove "my $x if cond()" construction.

U   trunk/cgi-bin/LJ/SUP/RPC/Command/get_entries.pm
U   trunk/cgi-bin/LJ/SUP/RPC/Command/get_recent_entries.pm
U   trunk/cgi-bin/LJ/Widget/AddPromoSet.pm
U   trunk/cgi-bin/LJ/Widget/CreateAccountLevel.pm
U   trunk/cgi-bin/LJ/Widget/OfficialJournals.pm
U   trunk/cgi-bin/LJ/Widget/ShoppingCartStatus.pm
Modified: trunk/cgi-bin/LJ/SUP/RPC/Command/get_entries.pm
===================================================================
--- trunk/cgi-bin/LJ/SUP/RPC/Command/get_entries.pm	2009-04-08 07:33:57 UTC (rev 7180)
+++ trunk/cgi-bin/LJ/SUP/RPC/Command/get_entries.pm	2009-04-08 07:40:14 UTC (rev 7181)
@@ -13,7 +13,7 @@
 sub make_skip_fields {
     my ($self, $is_friends, $skip, $limit, $itemnum, $lastdate) = @_;
 
-    my $here = $skip if $skip =~ m!^(\d\d\d\d)/(\d\d)/(\d\d)\b!;
+    my $here = ($skip =~ m!^(\d\d\d\d)/(\d\d)/(\d\d)\b!) ? $skip : '';
     if ($here) {
         # find near days
         my ($prev, $next);

Modified: trunk/cgi-bin/LJ/SUP/RPC/Command/get_recent_entries.pm
===================================================================
--- trunk/cgi-bin/LJ/SUP/RPC/Command/get_recent_entries.pm	2009-04-08 07:33:57 UTC (rev 7180)
+++ trunk/cgi-bin/LJ/SUP/RPC/Command/get_recent_entries.pm	2009-04-08 07:40:14 UTC (rev 7181)
@@ -44,8 +44,9 @@
         }
     }
 
-    my $ymd = $skip if $skip =~ m!^(\d\d\d\d)/(\d\d)/(\d\d)\b!;
-
+    my $ymd = ($skip =~ m!^(\d\d\d\d)/(\d\d)/(\d\d)\b!)
+                ? $skip
+                : '';
     my $err;
     my @itemids;
     my $journal = $self->journal;

Modified: trunk/cgi-bin/LJ/Widget/AddPromoSet.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/AddPromoSet.pm	2009-04-08 07:33:57 UTC (rev 7180)
+++ trunk/cgi-bin/LJ/Widget/AddPromoSet.pm	2009-04-08 07:40:14 UTC (rev 7181)
@@ -14,7 +14,7 @@
     my $get = delete $opts{get};
     my $post = delete $opts{post};
 
-    my $setdom = $get->{setdom} if LJ::PromoText->is_valid_domain($get->{setdom});
+    my $setdom = LJ::PromoText->is_valid_domain($get->{setdom}) ? $get->{setdom} : '';
     my $setid = $get->{setid};
     die "Set domain is invalid or unspecified." unless $setdom || $setid;
 

Modified: trunk/cgi-bin/LJ/Widget/CreateAccountLevel.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/CreateAccountLevel.pm	2009-04-08 07:33:57 UTC (rev 7180)
+++ trunk/cgi-bin/LJ/Widget/CreateAccountLevel.pm	2009-04-08 07:40:14 UTC (rev 7181)
@@ -31,7 +31,7 @@
     $ret .= "<label for='plus_check'>" . $class->ml('widget.createaccountlevel.field.plus') . "</label></div>\n";
 
     ### paid
-    my @paid_checked = ( checked => "checked" ) if $u->in_class('paid');
+    my @paid_checked = $u->in_class('paid') ? ( checked => "checked" ) : ();
     $ret .= "<div class='paid-row'>";
     $ret .= "<div class='paid-info'>" . $class->html_check(
         name => 'ljcom_atype',

Modified: trunk/cgi-bin/LJ/Widget/OfficialJournals.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/OfficialJournals.pm	2009-04-08 07:33:57 UTC (rev 7180)
+++ trunk/cgi-bin/LJ/Widget/OfficialJournals.pm	2009-04-08 07:40:14 UTC (rev 7181)
@@ -58,7 +58,7 @@
     my $news_printed = 0;
     if ($print_news) {
         my $entry = $latest_entries->{$news->id};
-        my $delta = time() - $entry->logtime_unix if $entry;
+        my $delta = $entry ? (time() - $entry->logtime_unix) : 0;
 
         # Only show news that is from the past seven days
         if ($entry && $delta < 86400 * 7) {

Modified: trunk/cgi-bin/LJ/Widget/ShoppingCartStatus.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/ShoppingCartStatus.pm	2009-04-08 07:33:57 UTC (rev 7180)
+++ trunk/cgi-bin/LJ/Widget/ShoppingCartStatus.pm	2009-04-08 07:40:14 UTC (rev 7181)
@@ -15,15 +15,14 @@
     my $get = $class->get_args;
     my $cart = $get->{'cart'} || $BML::COOKIE{cart};
     my $cartobj = LJ::Pay::load_cart($cart);
-    my $cartnum = scalar @{$cartobj->{'items'}} if ($cartobj);
     my $base_url = "$LJ::SITEROOT/pay/index.bml";
-    my $url = "$base_url?c=$cart" if ($cartobj);
 
     my $body;
     $body .= "<div><h2 class='solid-blue'>Shopping Cart</h2>";
-
     $body .= "<div class='indent_sm'>";
     if ($cartobj) {
+        my $cartnum = scalar @{$cartobj->{'items'}};
+        my $url     = "$base_url?c=$cart";
         $body .= "There are <a href='$url'>$cartnum items in your cart</a>.";
         $body .= "<p><form action='$base_url' method='GET'>"
                  . "<input type='hidden' value='$cart' name='c'>"
@@ -41,7 +40,6 @@
         $body .= "Your cart is empty.";
     }
     $body .= "</div>";
-
     $body .= "</div>";
 
     return $body;

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments