// small perf optimization

This commit is contained in:
Rémi Gaillard committed 2013-01-09 14:35:06 +01:00
1 parent db162ee987
commit 4a8c138a2c
1 file changed
+7 -3
+7 -3
View File
@@ -295,13 +295,17 @@ class GroupCore extends ObjectModel
*/ */
public static function getCurrent() public static function getCurrent()
{ {
static $groups = array();
$customer = Context::getContext()->customer; $customer = Context::getContext()->customer;
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
if (Validate::isLoadedObject($customer)) if (Validate::isLoadedObject($customer))
$id_group = (int)$customer->id_default_group; $id_group = (int)$customer->id_default_group;
else
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
return new Group($id_group); if (!isset($groups[$id_group]))
$groups[$id_group] = new Group($id_group);
return $groups[$id_group];
} }
} }