diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-07 04:54:18 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-07 04:54:18 +0000 |
commit | 3ede61995539d7f4b1ee0b7f30897b849400f490 (patch) | |
tree | ecfb961c8e28ce0edfac5e050276928a94f17993 /modules/user | |
parent | 37fcdbc67cd5591107c93016d1d3bb109be5e9e6 (diff) | |
download | brdo-3ede61995539d7f4b1ee0b7f30897b849400f490.tar.gz brdo-3ede61995539d7f4b1ee0b7f30897b849400f490.tar.bz2 |
#619666 follow-up by effulgentsia: Make performance-critical usage of drupal_static() grokkable.
Diffstat (limited to 'modules/user')
-rw-r--r-- | modules/user/user.module | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index e9e3849fa..41f83d945 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -719,9 +719,11 @@ function user_access($string, $account = NULL) { // To reduce the number of SQL queries, we cache the user's permissions // in a static variable. // 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__]; + static $drupal_static_fast; + if (!isset($drupal_static_fast)) { + $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__); + } + $perm = &$drupal_static_fast['perm']; if (!isset($perm[$account->uid])) { $role_permissions = user_role_permissions($account->roles); |