php - Magento: Mage::registry('current_product') efficient? -


this obvious if know process behind it.. when use mage::registry('current_product') on product page, example, merely referencing "loaded" or loading every time run line of code?

in other words, more efficient? (pseudocode below)

mage::registry('current_product')->getname() on , on 

or...

$temp = mage::registry('current_product') $temp->getname() on , on 

calling

mage::registry('current_product')->getname() 

over , on again slightly less efficient

$temp = mage::registry('current_product') $temp->getname() on , on 

but it's not bad i'd super concerned about. if you're setting coding style, pick second. if have bunch of old code former, don't worry performance.

the product won't reloaded database when call mage::registry('current_product') — all method return object reference that's been stored on static array of mage class.

the reason former less efficient is, if take @ source of registry

#file: app/mage.php public static function registry($key) {     if (isset(self::$_registry[$key])) {         return self::$_registry[$key];     }     return null; } 

you'll see magento check if key set before returning value. check, theoretically, more work grabbing registry once , reusing variable.

however, practically speaking, you're going have bigger bottlenecks before real problem.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -