From b14349889e9e51fb44934694030e95306918e3bd Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 20 Nov 2009 06:12:45 +0000 Subject: #619666 by effulgentsia, casey, and catch: Changed Introduce new pattern for drupal_static() in performance-critical functions. --- modules/user/user.module | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules/user/user.module') diff --git a/modules/user/user.module b/modules/user/user.module index 2772b5ffb..a244ea887 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -679,7 +679,10 @@ function user_role_permissions($roles = array()) { */ function user_access($string, $account = NULL) { global $user; - $perm = &drupal_static(__FUNCTION__, array()); + // Use the advanced drupal_static() pattern, since this is called very often. + static $drupal_static = array(); + isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__)); + $perm = &$drupal_static[__FUNCTION__]; if (!isset($account)) { $account = $user; -- cgit v1.2.3