Skip to content

Commit

Permalink
peephole optimization to singletons, i.e., new self vs. $c = __CLASS_…
Browse files Browse the repository at this point in the history
…_; new $c
  • Loading branch information
vipsoft committed Oct 28, 2010
1 parent 79030f7 commit cb3c11b
Show file tree
Hide file tree
Showing 32 changed files with 60 additions and 92 deletions.
5 changes: 2 additions & 3 deletions core/API/Proxy.php
Expand Up @@ -53,9 +53,8 @@ protected function __construct()
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/DataTable/Manager.php
Expand Up @@ -29,9 +29,8 @@ class Piwik_DataTable_Manager
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
3 changes: 1 addition & 2 deletions core/Db/Schema.php
Expand Up @@ -33,8 +33,7 @@ static public function getInstance()
{
if (self::$instance === null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/FrontController.php
Expand Up @@ -48,9 +48,8 @@ class Piwik_FrontController
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/Menu/Admin.php
Expand Up @@ -22,9 +22,8 @@ class Piwik_Menu_Admin extends Piwik_Menu_Abstract
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/Menu/Main.php
Expand Up @@ -23,9 +23,8 @@ class Piwik_Menu_Main extends Piwik_Menu_Abstract
static public function getInstance()
{
if (self::$instance == null)
{
$c = get_class();
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/Menu/Top.php
Expand Up @@ -22,9 +22,8 @@ class Piwik_Menu_Top extends Piwik_Menu_Abstract
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/Option.php
Expand Up @@ -31,9 +31,8 @@ class Piwik_Option
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/PluginsManager.php
Expand Up @@ -65,9 +65,8 @@ class Piwik_PluginsManager
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/Tracker/Config.php
Expand Up @@ -42,9 +42,8 @@ class Piwik_Tracker_Config
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions core/Translate.php
Expand Up @@ -24,9 +24,8 @@ class Piwik_Translate
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
4 changes: 1 addition & 3 deletions plugins/API/API.php
Expand Up @@ -43,7 +43,6 @@ public function getCssFiles($notification) {

$cssFiles[] = "plugins/API/css/styles.css";
}

}


Expand All @@ -62,8 +61,7 @@ static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/Actions/API.php
Expand Up @@ -23,8 +23,7 @@ static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/CoreAdminHome/API.php
Expand Up @@ -21,8 +21,7 @@ static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/DBStats/API.php
Expand Up @@ -20,9 +20,8 @@ class Piwik_DBStats_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/ExampleAPI/API.php
Expand Up @@ -45,8 +45,7 @@ static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/ExampleUI/API.php
Expand Up @@ -19,9 +19,8 @@ class Piwik_ExampleUI_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/Goals/API.php
Expand Up @@ -23,9 +23,8 @@ class Piwik_Goals_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/LanguagesManager/API.php
Expand Up @@ -21,9 +21,8 @@ class Piwik_LanguagesManager_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/Live/API.php
Expand Up @@ -28,8 +28,7 @@ static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down Expand Up @@ -227,8 +226,9 @@ private function loadLastVisitorDetailsFromDatabase($idSite, $period = false, $d

array_push( $where, Piwik_Common::prefixTable('log_visit') . ".visit_first_action_time BETWEEN ? AND ?");
array_push( $whereBind,
$processedPeriod->getDateStart()->toString(),
$processedPeriod->getDateEnd()->addDay(1)->toString());
$processedPeriod->getDateStart()->toString(),
$processedPeriod->getDateEnd()->addDay(1)->toString()
);
}

$sqlWhere = "";
Expand Down
5 changes: 2 additions & 3 deletions plugins/PDFReports/API.php
Expand Up @@ -25,9 +25,8 @@ class Piwik_PDFReports_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/Provider/API.php
Expand Up @@ -26,9 +26,8 @@ class Piwik_Provider_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/Referers/API.php
Expand Up @@ -26,8 +26,7 @@ static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/SEO/API.php
Expand Up @@ -27,9 +27,8 @@ class Piwik_SEO_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/SitesManager/API.php
Expand Up @@ -24,9 +24,8 @@ class Piwik_SitesManager_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/UserCountry/API.php
Expand Up @@ -27,9 +27,8 @@ class Piwik_UserCountry_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/UserSettings/API.php
Expand Up @@ -25,9 +25,8 @@ class Piwik_UserSettings_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/UsersManager/API.php
Expand Up @@ -24,9 +24,8 @@ class Piwik_UsersManager_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/VisitFrequency/API.php
Expand Up @@ -20,9 +20,8 @@ class Piwik_VisitFrequency_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/VisitTime/API.php
Expand Up @@ -20,9 +20,8 @@ class Piwik_VisitTime_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/VisitorInterest/API.php
Expand Up @@ -20,9 +20,8 @@ class Piwik_VisitorInterest_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down
5 changes: 2 additions & 3 deletions plugins/VisitsSummary/API.php
Expand Up @@ -20,9 +20,8 @@ class Piwik_VisitsSummary_API
static public function getInstance()
{
if (self::$instance == null)
{
$c = __CLASS__;
self::$instance = new $c();
{
self::$instance = new self;
}
return self::$instance;
}
Expand Down

0 comments on commit cb3c11b

Please sign in to comment.