Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r21520: LJSUP-11603 (optimize performance of S2 ...

Committer: ailyin
LJSUP-11603 (optimize performance of S2 comments pages)
U   trunk/cgi-bin/LJ/S2.pm
U   trunk/cgi-bin/LJ/Talk.pm
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-03-22 14:24:40 UTC (rev 21519)
+++ trunk/cgi-bin/LJ/S2.pm	2012-03-22 14:27:26 UTC (rev 21520)
@@ -1842,33 +1842,23 @@
     my ($epoch, $timezone) = @_;
     return undef unless $timezone;
 
-    if (ref $timezone eq "LJ::User") {
+    if ( LJ::isu($timezone) ) {
         $timezone = $timezone->prop("timezone");
         return undef unless $timezone;
     }
 
-    my $timezone_name;
-    if ( ref $timezone ) {
-        my ( undef, $filename, $line ) = caller(0);
-        warn "passing DateTime::TimeZone to LJ::S2::DateTime_tz " .
-            "is deprecated at $filename line $line\n";
-        $timezone_name = $timezone->name;
-    } else {
-        $timezone_name = $timezone;
-    }
-
-    unless ( exists $timezone_offsets_cache{$timezone_name} ) {
+    unless ( exists $timezone_offsets_cache{$timezone} ) {
         my $timezone_object = DateTime::TimeZone->new(
-            'name' => $timezone_name );
+            'name' => $timezone );
         if ($timezone_object) {
-            $timezone_offsets_cache{$timezone_name} =
+            $timezone_offsets_cache{$timezone} =
                 $timezone_object->offset_for_datetime( DateTime->now ) || 0;
         } else {
-            $timezone_offsets_cache{$timezone_name} = 0;
+            $timezone_offsets_cache{$timezone} = 0;
         }
     }
 
-    my $offset = $timezone_offsets_cache{$timezone_name};
+    my $offset = $timezone_offsets_cache{$timezone};
 
     my ( $sec, $min, $hour, $mday, $mon, $year, $wday ) =
         gmtime( $epoch + $offset );

Modified: trunk/cgi-bin/LJ/Talk.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk.pm	2012-03-22 14:24:40 UTC (rev 21519)
+++ trunk/cgi-bin/LJ/Talk.pm	2012-03-22 14:27:26 UTC (rev 21520)
@@ -2594,8 +2594,7 @@
     my $tz_remote;
     my $s2_ctx = [];  # ghetto fake S2 context object
     if ($remote) {
-        my $tz = $remote->prop("timezone");
-        $tz_remote = $tz ? eval { DateTime::TimeZone->new(name => $tz); } : undef;
+        my $tz_remote = $remote->prop('timezone') || undef;
     }    
 
     my $viewsome = $input->{viewsome};

Tags: ailyin, andy, livejournal, pm
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