From 27ec83ce40f3353e46b9947c8f2fffdd426f5e53 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 4 Dec 2011 21:39:17 +0100 Subject: [PATCH] MINOR i18n::_t() getter performance optimisation (saves 10% on default CMS execution!) --- i18n/i18n.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/i18n/i18n.php b/i18n/i18n.php index 011f7b5bd..403bc8391 100644 --- a/i18n/i18n.php +++ b/i18n/i18n.php @@ -1464,7 +1464,11 @@ class i18n extends Object implements TemplateGlobalProvider { $locale = i18n::get_locale(); $lang = i18n::get_lang_from_locale($locale); - foreach(self::get_translators() as $priority => $translators) { + // Only call getter if static isn't already defined (for performance reasons) + $translators = self::$translators; + if(!$translators) $translators = self::get_translators(); + + foreach($translators as $priority => $translators) { foreach($translators as $name => $translator) { $adapter = $translator->getAdapter();