Commit 37d9515b authored by webchick's avatar webchick

#528856 by catch: Optimize module_implements() by statically caching the maintenance mode variable.

parent 0d18cd68
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment