From 0e7c1835e00b330915a67b17069f45a96b280347 Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Wed, 14 Mar 2012 14:51:49 +0000 Subject: [PATCH] // FO : more optimizations with unnecessary instantiations git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14160 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Tools.php | 13 ++++++++----- modules/blockcart/blockcart.php | 8 +++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 7f73fecd5..0a3eff235 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -376,12 +376,15 @@ class ToolsCore { if (!$context) $context = Context::getContext(); - if (($id_lang = (int)Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang)) - $context->cookie->id_lang = $id_lang; - $language = new Language($id_lang); - if (Validate::isLoadedObject($language)) - $context->language = $language; + // update language only if new id is different from old id + if (($id_lang = (int)Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang) && $context->cookie->id_lang != (int)$id_lang) + { + $context->cookie->id_lang = $id_lang; + $language = new Language($id_lang); + if (Validate::isLoadedObject($language)) + $context->language = $language; + } } /** diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 8c3934eb9..0707fcdaf 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -49,12 +49,10 @@ class BlockCart extends Module global $errors; // Set currency - if (!(int)($params['cart']->id_currency)) - $currency = new Currency((int)$params['cookie']->id_currency); - else + if ((int)$params['cart']->id_currency && (int)$params['cart']->id_currency != $this->context->currency->id) $currency = new Currency((int)$params['cart']->id_currency); - if (!Validate::isLoadedObject($currency)) - $currency = new Currency((int)(Configuration::get('PS_CURRENCY_DEFAULT'))); + else + $currency = $this->context->currency; if ($params['cart']->id_customer) {