vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

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

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

U   trunk/cgi-bin/Apache/SendStats.pm
U   trunk/cgi-bin/JSON/Converter.pm
U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/LJ/Portal/Box.pm
U   trunk/cgi-bin/LJ/S2Theme.pm
U   trunk/cgi-bin/LJ/SMS/Message.pm
U   trunk/cgi-bin/LJ/Setting/SMS.pm
U   trunk/cgi-bin/LJ/URI.pm
U   trunk/cgi-bin/LJ/Widget/CreateAccountTheme.pm
U   trunk/cgi-bin/LJ/Widget/S2PropGroup.pm
U   trunk/cgi-bin/LJ/Widget/VerticalEntries.pm
U   trunk/cgi-bin/LJ/Widget.pm
Modified: trunk/cgi-bin/Apache/SendStats.pm
===================================================================
--- trunk/cgi-bin/Apache/SendStats.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/Apache/SendStats.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -20,7 +20,7 @@
     return OK if $r->main;
     return OK unless $LJ::HAVE_AVAIL && $LJ::FREECHILDREN_BCAST;
 
-    my $callback = $r->current_callback() if $r;
+    my $callback = $r ? $r->current_callback() : '';
     my $cleanup = $callback eq "PerlCleanupHandler";
     my $childinit = $callback eq "PerlChildInitHandler";
 

Modified: trunk/cgi-bin/JSON/Converter.pm
===================================================================
--- trunk/cgi-bin/JSON/Converter.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/JSON/Converter.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -48,8 +48,6 @@
 	my ($k,$v);
 	my %res;
 
-	my ($pre,$post) = $self->_upIndent() if($self->{pretty});
-
 	if(grep { $_ == $obj } @{ $self->{_stack_myself} }){
 		die "circle ref!";
 	}
@@ -74,6 +72,7 @@
 	$self->_downIndent() if($self->{pretty});
 
 	if($self->{pretty}){
+        my ($pre,$post) = $self->_upIndent();
 		my $del = $self->{_delstr};
 		return "{$pre"
 		 . join(",$pre", map { _stringfy($_) . $del .$res{$_} } keys %res)
@@ -91,8 +90,6 @@
 	my $obj  = shift;
 	my @res;
 
-	my ($pre,$post) = $self->_upIndent() if($self->{pretty});
-
 	if(grep { $_ == $obj } @{ $self->{_stack_myself} }){
 		die "circle ref!";
 	}
@@ -116,6 +113,7 @@
 	$self->_downIndent() if($self->{pretty});
 
 	if($self->{pretty}){
+	    my ($pre, $post) = $self->_upIndent();
 		return "[$pre" . join(",$pre" ,@res) . "$post]";
 	}
 	else{
@@ -177,7 +175,7 @@
 
 sub _initConvert {
 	my $self = shift;
-	my %opt  = %{ $_[0] } if(@_ > 0 and ref($_[0]) eq 'HASH');
+	my %opt  = (@_ > 0 and ref($_[0]) eq 'HASH') ?  %{ $_[0] } : ();
 
 	$self->{autoconv}    = $JSON::AUTOCONVERT if(!defined $self->{autoconv});
 	$self->{execcoderef} = $JSON::ExecCoderef if(!defined $self->{execcoderef});

Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Entry.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -2148,7 +2148,7 @@
         undef, $journalu->{'userid'}, $modid);
 
     use Storable;
-    my $req = Storable::thaw($frozen) if $frozen;
+    my $req = $frozen ? Storable::thaw($frozen) : {};
 
     my ($subject, $body) = ($req->{subject}, $req->{event});
     return 0 unless $body;

Modified: trunk/cgi-bin/LJ/Portal/Box.pm
===================================================================
--- trunk/cgi-bin/LJ/Portal/Box.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Portal/Box.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -183,7 +183,7 @@
 sub col {
     my LJ::Portal::Box $self = shift;
     if ( $_[0] ) {
-        my $newcol = shift if $_[0] =~ /^[A-Z]$/i;
+        my $newcol = ($_[0] =~ /^[A-Z]$/i) ? shift : '';
         $self->{'col'} = $newcol;
         $self->{'u'}->do("UPDATE portal_config SET col=? WHERE userid=? AND pboxid=?",
                           undef, $self->{'col'}, $self->{'u'}->{'userid'}, $self->{'pboxid'});
@@ -197,7 +197,7 @@
     my LJ::Portal::Box $self = shift;
     my $userid = $self->{'u'}->{'userid'};
     if ( $_[0] ) {
-        my $neworder = shift if $_[0] =~ /^\d$/;
+        my $neworder = ($_[0] =~ /^\d$/) ? shift : '';
         $self->{'sortorder'} = $neworder;
         $self->{'u'}->do("UPDATE portal_config SET sortorder=? WHERE userid=? AND pboxid=?",
                           undef, $self->{'sortorder'}, $userid, $self->{'pboxid'});

Modified: trunk/cgi-bin/LJ/S2Theme.pm
===================================================================
--- trunk/cgi-bin/LJ/S2Theme.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/S2Theme.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -601,7 +601,7 @@
 
     # get the styleid of the _for_preview style
     my $styleid = $u->prop('theme_preview_styleid');
-    my $style = LJ::S2::load_style($styleid) if $styleid;
+    my $style = $styleid ? LJ::S2::load_style($styleid) : '';
     if (!$styleid || !$style) {
         $styleid = LJ::S2::create_style($u, "_for_preview");
         $u->set_prop('theme_preview_styleid', $styleid);

Modified: trunk/cgi-bin/LJ/SMS/Message.pm
===================================================================
--- trunk/cgi-bin/LJ/SMS/Message.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/SMS/Message.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -815,7 +815,7 @@
         my $class_key = delete $opts{class_key};
 
         # explicit class_key
-        my $explicit = 1 if $class_key;
+        my $explicit = $class_key ? 1 : 0;
 
         # fall back to other means
         $class_key ||=

Modified: trunk/cgi-bin/LJ/Setting/SMS.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/SMS.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Setting/SMS.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -26,7 +26,7 @@
     my $key = $class->pkgkey;
 
     my $current_msisdn = $class->get_arg($args, "sms_phone") || $u->sms_mapped_number;
-    my ($area, $prefix, $num) = $current_msisdn =~ /\+1(\d{3})(\d{3})(\d{4})/ if $current_msisdn;
+    my ($area, $prefix, $num) = $current_msisdn =~ /\+1(\d{3})(\d{3})(\d{4})/;
     $current_msisdn = "$area-$prefix-$num" if $area && $prefix && $num;
 
     my $carrier = $class->get_arg($args, "sms_carrier") || $u->prop("sms_carrier");

Modified: trunk/cgi-bin/LJ/URI.pm
===================================================================
--- trunk/cgi-bin/LJ/URI.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/URI.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -46,7 +46,7 @@
     $full_uri .= "?$args" if $args;
     if (my $v = LJ::Vertical->load_by_url($full_uri)) {
         if ($v->is_canonical_url($full_uri)) {
-            my $args_for_redir = "?$args" if $args;
+            my $args_for_redir = $args ? "?$args" : '';
             return Apache::LiveJournal::redir($r, $v->url . $args_for_redir);
         } else {
             return LJ::URI->bml_handler($r, "explore/index.bml");

Modified: trunk/cgi-bin/LJ/Widget/CreateAccountTheme.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/CreateAccountTheme.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Widget/CreateAccountTheme.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -44,7 +44,7 @@
         $image_class =~ s/\//_/;
         my $name = $theme->name . ", " . $theme->layout_name;
 
-        my @checked = ( checked => "checked" ) if $current_theme->uniq eq $uniq;
+        my @checked = $current_theme->uniq eq $uniq ? ( checked => "checked" ) : ();
 
         $ret .= "<tr>" if $count % 3 == 0;
         $ret .= "<td class='theme-box'>";

Modified: trunk/cgi-bin/LJ/Widget/S2PropGroup.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/S2PropGroup.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Widget/S2PropGroup.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -107,7 +107,7 @@
                 # need to print the header inside the foreach because we don't want it printed if
                 # there's no props in this group that are also in this subheader
                 unless ($header_printed) {
-                    my $prop_list_class = " first" if $subheader_counter == 1;
+                    my $prop_list_class = ($subheader_counter == 1) ? " first" : '';
 
                     $ret .= "<div class='subheader subheader-$propgroup on' id='subheader__${propgroup}__${subheader}'>$subheaders{$subheader}</div>";
                     $ret .= "<table cellspacing='0' class='prop-list$prop_list_class' id='proplist__${propgroup}__${subheader}'>";

Modified: trunk/cgi-bin/LJ/Widget/VerticalEntries.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/VerticalEntries.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Widget/VerticalEntries.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -37,7 +37,8 @@
     my @entries_this_page = $vertical->entries( start => $start_index, limit => $num_entries_this_page + 1 );
 
     # pop off the last entry if we got more than we need, since we won't display it
-    my $last_entry = pop @entries_this_page if @entries_this_page > $num_entries_this_page;
+    my $last_entry = undef;
+       $last_entry = pop @entries_this_page if @entries_this_page > $num_entries_this_page;
 
     my $title_displayed = 0;
     my $count = 0;

Modified: trunk/cgi-bin/LJ/Widget.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget.pm	2009-04-08 07:35:22 UTC (rev 15110)
+++ trunk/cgi-bin/LJ/Widget.pm	2009-04-08 07:39:27 UTC (rev 15111)
@@ -46,7 +46,7 @@
     if ($class->authas) {
         my $u = $opts{authas} || $BMLCodeBlock::GET{authas} || $BMLCodeBlock::POST{authas};
         $u = LJ::load_user($u) unless LJ::isu($u);
-        my $authas = $u->user if LJ::isu($u);
+        my $authas = LJ::isu($u) ? $u->user : '';
 
         if ($authas && !$LJ::REQ_GLOBAL{widget_authas_form}) {
             $ret .= $class->html_hidden({ name => "authas", value => $authas, id => "_widget_authas" });

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