diff --git a/includes/registry.inc b/includes/registry.inc
index 35697d5..4b4acf0 100644
--- a/includes/registry.inc
+++ b/includes/registry.inc
@@ -354,6 +354,8 @@ function _bootstrap_process_theme_registry_suggestions(&$registry, $themes) {
 
   // Iterate over each theme passed.
   foreach ($themes as $theme) {
+    // Find functions matching the specific theme.
+    $theme_functions = preg_grep('/^' . $theme . '_/S', $functions['user']);
     // Iterate over each registered hook.
     foreach ($registry as $hook => $info) {
       // The pattern to match.
@@ -367,7 +369,7 @@ function _bootstrap_process_theme_registry_suggestions(&$registry, $themes) {
       // Iterate over the [pre]process phases.
       foreach ($variable_process_phases as $phase_key => $phase) {
         // Find functions matching the specific theme, phase and pattern.
-        if ($matches = preg_grep('/^' . $theme . '_' . $phase . '_' . $pattern . '/', $functions['user'])) {
+        if ($matches = preg_grep('/^' . $theme . '_' . $phase . '_' . $pattern . '/', $theme_functions)) {
           foreach ($matches as $match) {
             // Determine the current theme implementation.
             $hook = substr($match, strlen($theme . '_' . $phase) + 1);
