Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance optimization by replacing is_null with === null #201

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static function objects($key = null)
if (!self::$_objects) {
self::$_objects = new Varien_Object_Cache;
}
if (is_null($key)) {
if ($key === null) {
return self::$_objects;
} else {
return self::$_objects->load($key);
Expand Down Expand Up @@ -730,7 +730,7 @@ public static function isInstalled()
*/
public static function log($message, $level = null, $file = 'system.log', $forceLog = false)
{
$level = is_null($level) ? Zend_Log::DEBUG : $level;
$level = $level === null ? Zend_Log::DEBUG : $level;
if (empty($file) || $file == 'system.log') {
$file = 'system.log';
$key = Mage_Core_Model_Logger::LOGGER_SYSTEM;
Expand Down Expand Up @@ -865,7 +865,7 @@ public static function getScriptSystemUrl($folder, $exitIfNot = false)
}
}

if (is_null($baseUrl)) {
if ($baseUrl === null) {
$errorMessage = "Unable detect system directory: $folder";
if ($exitIfNot) {
// exit because of infinity loop
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/AdminNotification/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Mage_AdminNotification_Helper_Data extends Mage_Core_Helper_Abstract
*/
public function getLatestNotice()
{
if (is_null($this->_latestNotice)) {
if ($this->_latestNotice === null) {
$this->_latestNotice = Mage::getModel('Mage_AdminNotification_Model_Inbox')->loadLatestNotice();
}
return $this->_latestNotice;
Expand All @@ -85,7 +85,7 @@ public function getLatestNotice()
*/
public function getUnreadNoticeCount($severity)
{
if (is_null($this->_unreadNoticeCounts)) {
if ($this->_unreadNoticeCounts === null) {
$this->_unreadNoticeCounts = Mage::getModel('Mage_AdminNotification_Model_Inbox')->getNoticeStatus();
}
return isset($this->_unreadNoticeCounts[$severity]) ? $this->_unreadNoticeCounts[$severity] : 0;
Expand All @@ -99,7 +99,7 @@ public function getUnreadNoticeCount($severity)
*/
public function getPopupObjectUrl($withExt = false)
{
if (is_null($this->_popupUrl)) {
if ($this->_popupUrl === null) {
$sheme = Mage::app()->getFrontController()->getRequest()->isSecure()
? 'https://'
: 'http://';
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function _construct()
*/
public function getFeedUrl()
{
if (is_null($this->_feedUrl)) {
if ($this->_feedUrl === null) {
$this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://')
. Mage::getStoreConfig(self::XML_FEED_URL_PATH);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/AdminNotification/Model/Inbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getSeverities($severity = null)
self::SEVERITY_NOTICE => Mage::helper('Mage_AdminNotification_Helper_Data')->__('notice'),
);

if (!is_null($severity)) {
if ($severity !== null) {
if (isset($severities[$severity])) {
return $severities[$severity];
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/AdminNotification/Model/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function isSurveyViewed()
public static function saveSurveyViewed($viewed)
{
$flagData = self::_getFlagModel()->getFlagData();
if (is_null($flagData)) {
if ($flagData === null) {
$flagData = array();
}
$flagData = array_merge($flagData, array('survey_viewed' => (bool)$viewed));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public function getStore()

public function getRoot($parentNodeCategory=null, $recursionLevel=3)
{
if (!is_null($parentNodeCategory) && $parentNodeCategory->getId()) {
if ($parentNodeCategory !== null && $parentNodeCategory->getId()) {
return $this->getNode($parentNodeCategory, $recursionLevel);
}
$root = Mage::registry('root');
if (is_null($root)) {
if ($root === null) {
$storeId = (int) $this->getRequest()->getParam('store');

if ($storeId) {
Expand Down Expand Up @@ -191,7 +191,7 @@ public function getEditUrl()
public function getRootIds()
{
$ids = $this->getData('root_ids');
if (is_null($ids)) {
if ($ids === null) {
$ids = array();
foreach (Mage::app()->getGroups() as $store) {
$ids[] = $store->getRootCategoryId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function _getAdditionalElementTypes()

protected function _getParentCategoryOptions($node=null, &$options=array())
{
if (is_null($node)) {
if ($node === null) {
$node = $this->getRoot();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function getGridUrl()
protected function _getSelectedProducts()
{
$products = $this->getRequest()->getPost('selected_products');
if (is_null($products)) {
if ($products === null) {
$products = $this->getCategory()->getProductsPosition();
return array_keys($products);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getCategoryCollection()
{
$storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
$collection = $this->getData('category_collection');
if (is_null($collection)) {
if ($collection === null) {
$collection = Mage::getModel('Mage_Catalog_Model_Category')->getCollection();

/* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
Expand Down Expand Up @@ -187,7 +187,7 @@ public function getLoadTreeUrl($expanded=null)
{
$params = array('_current'=>true, 'id'=>null,'store'=>null);
if (
(is_null($expanded) && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getIsTreeWasExpanded())
($expanded === null && Mage::getSingleton('Mage_Backend_Model_Auth_Session')->getIsTreeWasExpanded())
|| $expanded == true) {
$params['expand_all'] = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ protected function _getSetId()
public function getIsCurrentSetDefault()
{
$isDefault = $this->getData('is_current_set_default');
if (is_null($isDefault)) {
if ($isDefault === null) {
$defaultSetId = Mage::getModel('Mage_Eav_Model_Entity_Type')
->load(Mage::registry('entityType'))
->getDefaultAttributeSetId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getProduct()
$this->setData('product', Mage::registry('product'));
}
$product = $this->getData('product');
if (is_null($product->getTypeInstance()->getStoreFilter($product))) {
if ($product->getTypeInstance()->getStoreFilter($product) === null) {
$product->getTypeInstance()->setStoreFilter(Mage::app()->getStore($product->getStoreId()), $product);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getProduct()
$this->setData('product', Mage::registry('product'));
}
$product = $this->getData('product');
if (is_null($product->getTypeInstance()->getStoreFilter($product))) {
if ( $product->getTypeInstance()->getStoreFilter($product) === null) {
$product->getTypeInstance()->setStoreFilter(Mage::app()->getStore($product->getStoreId()), $product);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getOptionHtml(Mage_Catalog_Model_Product_Option $option)
$renderer = $this->getOptionRender(
$this->getGroupOfOption($option->getType())
);
if (is_null($renderer['renderer'])) {
if ($renderer['renderer'] === null) {
$renderer['renderer'] = $this->getLayout()->createBlock($renderer['block'])
->setTemplate($renderer['template'])
->setSkipJsReloadPrice(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create extends Ma
*/
public function getConfig()
{
if (is_null($this->_config)) {
if ($this->_config === null) {
$this->_config = new Varien_Object();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ public function getOptionValues()

if ($this->getProduct()->getStoreId() != '0') {
$value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title',
is_null($option->getStoreTitle()));
$value['scopeTitleDisabled'] = is_null($option->getStoreTitle())?'disabled':null;
$option->getStoreTitle() === null);
$value['scopeTitleDisabled'] = $option->getStoreTitle() === null?'disabled':null;
}

if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
Expand All @@ -263,15 +263,15 @@ public function getOptionValues()

if ($this->getProduct()->getStoreId() != '0') {
$value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
$_value->getOptionId(), 'title', is_null($_value->getStoreTitle()),
$_value->getOptionId(), 'title', $_value->getStoreTitle() === null,
$_value->getOptionTypeId());
$value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle())
$value['optionValues'][$i]['scopeTitleDisabled'] = $_value->getStoreTitle() === null
? 'disabled' : null;
if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
$value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
$_value->getOptionId(), 'price', is_null($_value->getstorePrice()),
$_value->getOptionId(), 'price', $_value->getstorePrice() === null,
$_value->getOptionTypeId());
$value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice())
$value['optionValues'][$i]['scopePriceDisabled'] = $_value->getStorePrice() === null
? 'disabled' : null;
}
}
Expand All @@ -289,8 +289,8 @@ public function getOptionValues()
if ($this->getProduct()->getStoreId() != '0' &&
$scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
$value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(),
'price', is_null($option->getStorePrice()));
$value['scopePriceDisabled'] = is_null($option->getStorePrice())?'disabled':null;
'price', $option->getStorePrice() === null);
$value['scopePriceDisabled'] = $option->getStorePrice() === null?'disabled':null;
}
}
$values[] = new Varien_Object($value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function isMultiWebsites()
*/
public function getWebsites()
{
if (!is_null($this->_websites)) {
if ($this->_websites !== null) {
return $this->_websites;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function getProduct()
*/
public function getAttributeTabBlock()
{
if (is_null(Mage::helper('Mage_Adminhtml_Helper_Catalog')->getAttributeTabBlock())) {
if (Mage::helper('Mage_Adminhtml_Helper_Catalog')->getAttributeTabBlock() === null) {
return $this->_attributeTabBlock;
}
return Mage::helper('Mage_Adminhtml_Helper_Catalog')->getAttributeTabBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function __construct(array $attributes = array())
public function getDefaultHtml()
{
$html = $this->getData('default_html');
if (is_null($html)) {
if ($html === null) {
$html = ($this->getNoSpan() === true) ? '' : '<span class="field-row">' . "\n";
$html .= $this->getLabelHtml();
$html .= $this->getElementHtml();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Enabled extends Vari
*/
public function getElementHtml()
{
if (is_null($this->getValue())) {
if ($this->getValue() === null) {
$this->setValue(Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_USE_CONFIG);
}
return parent::getElementHtml();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Msrp_Price extends Varien
*/
public function getElementHtml()
{
if (is_null($this->getValue())) {
if ($this->getValue() === null) {
$this->setValue(Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG);
}
return parent::getElementHtml();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ protected function _addNewCustomerFormFields($form, $fieldset)

$websites = array();
foreach (Mage::app()->getWebsites(true) as $website) {
$websites[$website->getId()] = !is_null($website->getDefaultStore());
$websites[$website->getId()] = $website->getDefaultStore() !== null;
}
$prefix = $form->getHtmlIdPrefix();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function _getOptions()

public function getCondition()
{
if(is_null($this->getValue())) {
if($this->getValue() === null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function _beforeToHtml()
$this->_groupedCollection = array();

foreach ($this->_collection as $sale) {
if (!is_null($sale->getStoreId())) {
if ($sale->getStoreId() !== null) {
$store = Mage::app()->getStore($sale->getStoreId());
$websiteId = $store->getWebsiteId();
$groupId = $store->getGroupId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function getEscapedValue($index = null)
return false;
}
$value = $this->getValue();
if (is_array($value) && is_null($index)) {
if (is_array($value) && $index === null) {
$index = 'value';
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function _construct()

public function getHeaderText()
{
if(!is_null(Mage::registry('current_group')->getId())) {
if(Mage::registry('current_group')->getId() !== null) {
return Mage::helper('Mage_Customer_Helper_Data')->__('Edit Customer Group "%s"', $this->escapeHtml(Mage::registry('current_group')->getCustomerGroupCode()));
} else {
return Mage::helper('Mage_Customer_Helper_Data')->__('New Customer Group');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function _prepareLayout()
)
);

if (!is_null($customerGroup->getId())) {
if ($customerGroup->getId() !== null) {
// If edit add id
$form->addField('id', 'hidden',
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Mage_Adminhtml_Block_Customer_Sales_Order_Address_Form_Renderer_Vat
*/
public function getValidateButton()
{
if (is_null($this->_validateButton)) {
if ($this->_validateButton === null) {
/** @var $form Varien_Data_Form */
$form = $this->_element->getForm();

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function setCurrency($currency)
*/
public function getCurrency()
{
if (is_null($this->_currentCurrencyCode)) {
if ($this->_currentCurrencyCode === null) {
if ($this->getRequest()->getParam('store')) {
$this->_currentCurrencyCode = Mage::app()->getStore($this->getRequest()->getParam('store'))->getBaseCurrency();
} else if ($this->getRequest()->getParam('website')){
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ protected function getHeight()
*/
protected function _prepareData()
{
if (!is_null($this->getDataHelperName())) {
if ($this->getDataHelperName() !== null) {
$availablePeriods = array_keys($this->helper('Mage_Adminhtml_Helper_Dashboard_Data')->getDatePeriods());
$period = $this->getRequest()->getParam('period');
$this->getDataHelper()->setParam('period',
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Media/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getConfigJson()
*/
public function getConfig()
{
if(is_null($this->_config)) {
if($this->_config === null) {
$this->_config = new Varien_Object();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function _beforeToHtml()
*/
public function getQueueCollection()
{
if(is_null($this->_queueCollection)) {
if($this->_queueCollection === null) {
/** @var $this->_queueCollection Mage_Newsletter_Model_Resource_Queue_Collection */
$this->_queueCollection = Mage::getResourceSingleton('Mage_Newsletter_Model_Resource_Queue_Collection')
->addTemplateInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function _getOptions()

public function getCollection()
{
if(is_null($this->_websiteCollection)) {
if($this->_websiteCollection === null) {
$this->_websiteCollection = Mage::getResourceModel('Mage_Core_Model_Resource_Website_Collection')
->load();
}
Expand Down
Loading