Skip to content
This repository
Browse code

MINOR i18n::_t() getter performance optimisation (saves 10% on defaul…

…t CMS execution!)
  • Loading branch information...
commit 27ec83ce40f3353e46b9947c8f2fffdd426f5e53 1 parent 03de6e5
Ingo Schommer authored December 04, 2011

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  i18n/i18n.php
6  i18n/i18n.php
@@ -1464,7 +1464,11 @@ static function _t($entity, $string = "", $priority = 40, $context = "") {
1464 1464
 		$locale = i18n::get_locale();
1465 1465
 		$lang = i18n::get_lang_from_locale($locale);
1466 1466
 		
1467  
-		foreach(self::get_translators() as $priority => $translators) {
  1467
+		// Only call getter if static isn't already defined (for performance reasons)
  1468
+		$translators = self::$translators;
  1469
+		if(!$translators) $translators = self::get_translators();
  1470
+		
  1471
+		foreach($translators as $priority => $translators) {
1468 1472
 			foreach($translators as $name => $translator) {
1469 1473
 				$adapter = $translator->getAdapter();
1470 1474
 

0 notes on commit 27ec83c

Please sign in to comment.
Something went wrong with that request. Please try again.