From 601cfa56ce093e934edf6df9716d515a3c01137c Mon Sep 17 00:00:00 2001 From: "stefan.r" <stefan.r@551886.no-reply.drupal.org> Date: Thu, 29 Sep 2016 17:48:21 +0100 Subject: [PATCH] Issue #2720853 by joseph.olstad, donquixote, Fabianx, quicksketch: D7 Improve theme registry build performance by 85% --- CHANGELOG.txt | 2 +- includes/theme.inc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4e2001a8c112..6149eddedfde 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -8,7 +8,7 @@ Drupal 7.51, xxxx-xx-xx (development version) - If the page title is "0", it is now displayed. - Log messages are now XSS filtered on display. - Draggable tables do now work on touch screen devices. -- Numerous small performance improvements. +- Numerous performance improvements. - Numerous small bugfixes. - Numerous API documentation improvements. diff --git a/includes/theme.inc b/includes/theme.inc index ed2accdbdacc..8f929ac2142a 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1248,6 +1248,7 @@ function path_to_theme() { function drupal_find_theme_functions($cache, $prefixes) { $implementations = array(); $functions = get_defined_functions(); + $theme_functions = preg_grep('/^(' . implode(')|(', $prefixes) . ')_/', $functions['user']); foreach ($cache as $hook => $info) { foreach ($prefixes as $prefix) { @@ -1264,7 +1265,7 @@ function drupal_find_theme_functions($cache, $prefixes) { // intermediary suggestion. $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__'); if (!isset($info['base hook']) && !empty($pattern)) { - $matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $functions['user']); + $matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $theme_functions); if ($matches) { foreach ($matches as $match) { $new_hook = substr($match, strlen($prefix) + 1); -- GitLab