Permalink
Browse files

Issue #1387766 by dereine: Added Use fast drupal static pattern for l…

…ocale.
  • Loading branch information...
1 parent 1c51991 commit c99eba75eced22b89d96c0ca711e83e2be3cc894 @webchick webchick committed Jan 12, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 modules/locale/locale.module
@@ -630,7 +630,14 @@ function locale_modules_disabled($modules) {
*/
function locale($string = NULL, $context = NULL, $langcode = NULL) {
global $language;
- $locale_t = &drupal_static(__FUNCTION__);
+
+ // Use the advanced drupal_static() pattern, since this is called very often.
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['locale'] = &drupal_static(__FUNCTION__);
+ }
+ $locale_t = &$drupal_static_fast['locale'];
+
if (!isset($string)) {
// Return all cached strings if no string was specified

0 comments on commit c99eba7

Please sign in to comment.