summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-07 04:54:18 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-07 04:54:18 +0000
commit3ede61995539d7f4b1ee0b7f30897b849400f490 (patch)
treeecfb961c8e28ce0edfac5e050276928a94f17993 /includes/common.inc
parent37fcdbc67cd5591107c93016d1d3bb109be5e9e6 (diff)
downloadbrdo-3ede61995539d7f4b1ee0b7f30897b849400f490.tar.gz
brdo-3ede61995539d7f4b1ee0b7f30897b849400f490.tar.bz2
#619666 follow-up by effulgentsia: Make performance-critical usage of drupal_static() grokkable.
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc32
1 files changed, 20 insertions, 12 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 683cb16b2..6d69a18dd 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2278,9 +2278,11 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) {
*/
function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
// 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__));
- $timezones = &$drupal_static[__FUNCTION__];
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['timezones'] = &drupal_static(__FUNCTION__);
+ }
+ $timezones = &$drupal_static_fast['timezones'];
if (!isset($timezone)) {
global $user;
@@ -2519,9 +2521,11 @@ function url($path = NULL, array $options = array()) {
global $base_url, $base_secure_url, $base_insecure_url;
// 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__));
- $script = &$drupal_static[__FUNCTION__];
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['script'] = &drupal_static(__FUNCTION__);
+ }
+ $script = &$drupal_static_fast['script'];
if (!isset($script)) {
// On some web servers, such as IIS, we can't omit "index.php". So, we
@@ -4769,9 +4773,11 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)
*/
function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
// 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__));
- $functions = &$drupal_static[__FUNCTION__];
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['functions'] = &drupal_static(__FUNCTION__);
+ }
+ $functions = &$drupal_static_fast['functions'];
// Some alter hooks are invoked many times per page request, so statically
// cache the list of functions to call, and on subsequent calls, iterate
@@ -6271,9 +6277,11 @@ function drupal_check_incompatibility($v, $current_version) {
*/
function entity_get_info($entity_type = NULL) {
// 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__));
- $entity_info = &$drupal_static[__FUNCTION__];
+ static $drupal_static_fast;
+ if (!isset($drupal_static_fast)) {
+ $drupal_static_fast['entity_info'] = &drupal_static(__FUNCTION__);
+ }
+ $entity_info = &$drupal_static_fast['entity_info'];
if (empty($entity_info)) {
if ($cache = cache_get('entity_info')) {