From: Tim Otten Date: Sat, 12 Sep 2015 03:22:49 +0000 (-0700) Subject: CRM_Core_I18n::crm_translate_raw - Don't lookup $config->lcMessages for every string X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0d09647742ff9d8b13160ad19dd7800aaa1ceb6b;p=civicrm-core.git CRM_Core_I18n::crm_translate_raw - Don't lookup $config->lcMessages for every string Accessing `$config` is now be a little slower, and this function accounted for about half of all calls. --- diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index b0a8ad5ed3..36d3ccbdc3 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -50,6 +50,11 @@ class CRM_Core_I18n { */ private $_extensioncache = array(); + /** + * @var string + */ + private $locale; + /** * A locale-based constructor that shouldn't be called from outside of this class (use singleton() instead). * @@ -59,6 +64,7 @@ class CRM_Core_I18n { * @return \CRM_Core_I18n */ public function __construct($locale) { + $this->locale = $locale; if ($locale != '' and $locale != 'en_US') { $config = CRM_Core_Config::singleton(); @@ -336,16 +342,15 @@ class CRM_Core_I18n { } // do all wildcard translations first - $config = CRM_Core_Config::singleton(); - if (!isset(Civi::$statics[__CLASS__][$config->lcMessages])) { - if ($config->dsn && !CRM_Core_Config::isUpgradeMode()) { - Civi::$statics[__CLASS__][$config->lcMessages] = CRM_Core_BAO_WordReplacement::getLocaleCustomStrings($config->lcMessages); + if (!isset(Civi::$statics[__CLASS__][$this->locale])) { + if (defined('CIVICRM_DSN') && !CRM_Core_Config::isUpgradeMode()) { + Civi::$statics[__CLASS__][$this->locale] = CRM_Core_BAO_WordReplacement::getLocaleCustomStrings($this->locale); } else { - Civi::$statics[__CLASS__][$config->lcMessages] = array(); + Civi::$statics[__CLASS__][$this->locale] = array(); } } - $stringTable = Civi::$statics[__CLASS__][$config->lcMessages]; + $stringTable = Civi::$statics[__CLASS__][$this->locale]; $exactMatch = FALSE; if (isset($stringTable['enabled']['exactMatch'])) {