summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-08 15:03:29 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-08 15:03:29 +0000
commit37d9515b48964f9145f211268ff7cfaeab419aab (patch)
tree8ae9b08187f0ce18138a9ebc2da3492a0331d6d1 /includes
parent0d18cd681b5e5ed8e5df7d6303255a176b94bd33 (diff)
downloadbrdo-37d9515b48964f9145f211268ff7cfaeab419aab.tar.gz
brdo-37d9515b48964f9145f211268ff7cfaeab419aab.tar.bz2
#528856 by catch: Optimize module_implements() by statically caching the maintenance mode variable.
Diffstat (limited to 'includes')
-rw-r--r--includes/module.inc10
1 files changed, 8 insertions, 2 deletions
diff --git a/includes/module.inc b/includes/module.inc
index ffdb4c165..3e8d5339b 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -384,9 +384,15 @@ function module_hook($module, $hook) {
* the implementations are loaded as necessary.
*/
function module_implements($hook, $sort = FALSE) {
- static $implementations = array(), $sorted_implementations = array(), $loaded = array(), $cached_hooks = 0;
+ static $implementations = array(), $sorted_implementations = array(), $loaded = array(), $cached_hooks = 0, $maintenance;
- if (defined('MAINTENANCE_MODE')) {
+ // Use a static variable for maintenance mode to avoid the overhead of
+ // calling defined() each time the function is called.
+ if (!isset($maintenance)) {
+ $maintenance = defined('MAINTENANCE_MODE');
+ }
+
+ if ($maintenance) {
return _module_implements_maintenance($hook, $sort);
}
if ($hook === MODULE_IMPLEMENTS_CLEAR_CACHE) {