fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-18 10:52 am

[dw-free] better organization of LJ functions

[commit: http://hg.dwscoalition.org/dw-free/rev/dc603e008767]

http://bugs.dwscoalition.org/show_bug.cgi?id=3965

Removes this unnecessary helper function in favor of calling the method
directly and only loading the PageStats library in those files which use it.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/Apache/LiveJournal.pm
  • cgi-bin/LJ/S2.pm
  • cgi-bin/ljlib.pl
  • cgi-bin/weblib.pl
--------------------------------------------------------------------------------
diff -r 66024fba0e5d -r dc603e008767 cgi-bin/Apache/LiveJournal.pm
--- a/cgi-bin/Apache/LiveJournal.pm	Tue Oct 18 18:45:52 2011 +0800
+++ b/cgi-bin/Apache/LiveJournal.pm	Tue Oct 18 18:51:52 2011 +0800
@@ -34,6 +34,7 @@
 use LJ::AccessLogSink::DBIProfile;
 use Compress::Zlib;
 use XMLRPC::Transport::HTTP;
+use LJ::PageStats;
 use LJ::URI;
 use DW::Routing;
 use DW::Template;
@@ -1489,7 +1490,7 @@
     LJ::Hooks::run_hooks("insert_html_before_journalctx_body_close", \$before_body_close);
 
     # Insert pagestats HTML and Javascript
-    $before_body_close .= LJ::pagestats_obj()->render('journal');
+    $before_body_close .= LJ::PageStats->new->render( 'journal' );
 
     $html =~ s!</body>!$before_body_close</body>!i if $before_body_close;
 
diff -r 66024fba0e5d -r dc603e008767 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Tue Oct 18 18:45:52 2011 +0800
+++ b/cgi-bin/LJ/S2.pm	Tue Oct 18 18:51:52 2011 +0800
@@ -39,6 +39,7 @@
 use POSIX ();
 
 use DW::SiteScheme;
+use LJ::PageStats;
 
 # TEMP HACK
 sub get_s2_reader {
@@ -210,7 +211,7 @@
         unless $ctx->[S2::SCRATCH]->{siteviews_enabled};
 
     $page->{head_content} .= $extra_js;
-    $page->{head_content} .= LJ::pagestats_obj()->render_head( 'journal' );
+    $page->{head_content} .= LJ::PageStats->new->render_head( 'journal' );
 
     # inject the control strip JS, but only after any libraries have been injected
     $page->{head_content} .= LJ::control_strip_js_inject( user => $u->user, jquery => $beta_jquery )
diff -r 66024fba0e5d -r dc603e008767 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Tue Oct 18 18:45:52 2011 +0800
+++ b/cgi-bin/ljlib.pl	Tue Oct 18 18:51:52 2011 +0800
@@ -72,7 +72,6 @@
 use LJ::Comment;
 use LJ::ExternalSite;
 use LJ::Message;
-use LJ::PageStats;
 use LJ::AccessLogSink;
 use LJ::ConvUTF8;
 use LJ::Userpic;
@@ -2102,9 +2101,6 @@
     Carp::croak("Undefined subroutine: $AUTOLOAD");
 }
 
-sub pagestats_obj {
-    return LJ::PageStats->new;
-}
 
 sub conf_test {
     my ($conf, @args) = @_;
diff -r 66024fba0e5d -r dc603e008767 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Tue Oct 18 18:45:52 2011 +0800
+++ b/cgi-bin/weblib.pl	Tue Oct 18 18:51:52 2011 +0800
@@ -29,6 +29,7 @@
 use LJ::Subscription::Pending;
 use LJ::Directory::Search;
 use LJ::Directory::Constraint;
+use LJ::PageStats;
 
 # <LJFUNC>
 # name: LJ::img
@@ -3838,9 +3839,9 @@
 sub final_head_html {
     my $ret = "";
 
-    my $pagestats_obj = LJ::pagestats_obj();
-    $ret .= $pagestats_obj->render_head
-        if $pagestats_obj;
+    if ( my $pagestats_obj = LJ::PageStats->new ) {
+        $ret .= $pagestats_obj->render_head;
+    }
 
     return $ret;
 }
@@ -3850,9 +3851,9 @@
     my $before_body_close = "";
     LJ::Hooks::run_hooks('insert_html_before_body_close', \$before_body_close);
 
-    my $pagestats_obj = LJ::pagestats_obj();
-    $before_body_close .= $pagestats_obj->render
-        if $pagestats_obj;
+    if ( my $pagestats_obj = LJ::PageStats->new ) {
+        $before_body_close .= $pagestats_obj->render;
+    }
 
     return $before_body_close;
 }
--------------------------------------------------------------------------------