From c99eba75eced22b89d96c0ca711e83e2be3cc894 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Wed, 11 Jan 2012 23:21:05 -0500
Subject: [PATCH] Issue #1387766 by dereine: Added Use fast drupal static
 pattern for locale.

---
 modules/locale/locale.module | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 07884614a51e..0138f39644dc 100644
--- a/modules/locale/locale.module
+++ b/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
-- 
GitLab